2 dimensional scroll for a grid in Android
I have tried making a (potentially infinite) grid to scroll without success so far. I have a trouble rendering a GridView
that is out of the screen. That's why I would like to ask if there is any other component in android that could be used for this task?


add a comment |
I have tried making a (potentially infinite) grid to scroll without success so far. I have a trouble rendering a GridView
that is out of the screen. That's why I would like to ask if there is any other component in android that could be used for this task?


Could you add some more requirements, please? What should be on the grid? How often it will be updated? Is it about putting some graphical elements there and then just scrolling or is does it require to move that elements to different positions too?
– Gaket
Jan 11 at 2:09
try this stackoverflow.com/a/16303262/6587502
– Ashutosh Sagar
Jan 11 at 9:12
add a comment |
I have tried making a (potentially infinite) grid to scroll without success so far. I have a trouble rendering a GridView
that is out of the screen. That's why I would like to ask if there is any other component in android that could be used for this task?


I have tried making a (potentially infinite) grid to scroll without success so far. I have a trouble rendering a GridView
that is out of the screen. That's why I would like to ask if there is any other component in android that could be used for this task?




edited Jan 11 at 8:45


Karthikeyan
10518
10518
asked Jan 2 at 12:27
BanzaiTokyoBanzaiTokyo
5271821
5271821
Could you add some more requirements, please? What should be on the grid? How often it will be updated? Is it about putting some graphical elements there and then just scrolling or is does it require to move that elements to different positions too?
– Gaket
Jan 11 at 2:09
try this stackoverflow.com/a/16303262/6587502
– Ashutosh Sagar
Jan 11 at 9:12
add a comment |
Could you add some more requirements, please? What should be on the grid? How often it will be updated? Is it about putting some graphical elements there and then just scrolling or is does it require to move that elements to different positions too?
– Gaket
Jan 11 at 2:09
try this stackoverflow.com/a/16303262/6587502
– Ashutosh Sagar
Jan 11 at 9:12
Could you add some more requirements, please? What should be on the grid? How often it will be updated? Is it about putting some graphical elements there and then just scrolling or is does it require to move that elements to different positions too?
– Gaket
Jan 11 at 2:09
Could you add some more requirements, please? What should be on the grid? How often it will be updated? Is it about putting some graphical elements there and then just scrolling or is does it require to move that elements to different positions too?
– Gaket
Jan 11 at 2:09
try this stackoverflow.com/a/16303262/6587502
– Ashutosh Sagar
Jan 11 at 9:12
try this stackoverflow.com/a/16303262/6587502
– Ashutosh Sagar
Jan 11 at 9:12
add a comment |
3 Answers
3
active
oldest
votes
Depending on your requirements, it looks like either a table-like RecyclerView with infinite scrolling either some 2d game engine (in case if it's worth to bring it for this feature) might be an optimal solution for you.
RecyclerView
In case if you just want to store some objects (graphical or not - does not really matter, if you can pack them to the cells), you can use some kind of RecyclerView adapter with an extension for boundless scrolling.
This way you can save some memory using the views recycling mechanism. Using the detailed notification mechanisms (like item moved/deleted) you even can add some animations if the objects are moving.
In addition to a proposed solution like evrencoskun/TableView, I would suggest to glance on how the way how GridLayoutManger
works overall, here is the first post out of three in a relatively deep review of how the RecyclerView
and its LayoutManager
s work`, so you could tailor more lightweight solution for your particular case. There is a simple demo app, "Fixed two-way list" with "Large Grid" option may give you some idea of what will be built. You will need to extend it to work with infinite lists, but it should be simpler when you understand the internals.
2D engine
If the idea is to have some graphics over the tiles with arbitrary sizes and the feature is core for your app, it might be a good idea to consider using some 2d engine like libdx. They have many examples how to use it but of course it will cost you some storage and time to learn it: libgdx wike
Own solution
If neither of both suits your needs, I think, you will have to find your own solution from scratch. Don't forget to optimize it, as every infinite thing in Android, especially bound to graphics, may easily lead to Out of memory errors.
add a comment |
I would like to suggest this evrencoskun/TableView.
It allows you to scroll both horizontally and vertically.
<com.evrencoskun.tableview.TableView
android:id="@+id/content_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Thank you! It looks very interesting, I will definitely check it out!
– BanzaiTokyo
Jan 2 at 15:19
it looks like the table is not quite what I need. I need a grid to place graphic objects. I will see if I can come up with a custom component.
– BanzaiTokyo
Jan 3 at 21:46
add a comment |
might this link will be helpful for you
https://github.com/jess-anders/two-way-gridview
<?xml version="1.0" encoding="utf-8"?>
<com.jess.ui.TwoWayGridView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#E8E8E8"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:cacheColorHint="#E8E8E8"
app:columnWidth="80dp"
app:rowHeight="80dp"
app:numColumns="auto_fit"
app:numRows="auto_fit"
app:verticalSpacing="16dp"
app:horizontalSpacing="16dp"
app:stretchMode="spacingWidthUniform"
app:scrollDirectionPortrait="vertical"
app:scrollDirectionLandscape="horizontal"
app:gravity="center"/>
Thanks! I will check it out. But isn't this widget made for scrolling vertically OR horisontally? Does it do both?
– BanzaiTokyo
Jan 2 at 13:04
why does it work?please either highlight relevant sections or explain the snippet
– kkarakk
Jan 9 at 8:13
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54006399%2f2-dimensional-scroll-for-a-grid-in-android%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Depending on your requirements, it looks like either a table-like RecyclerView with infinite scrolling either some 2d game engine (in case if it's worth to bring it for this feature) might be an optimal solution for you.
RecyclerView
In case if you just want to store some objects (graphical or not - does not really matter, if you can pack them to the cells), you can use some kind of RecyclerView adapter with an extension for boundless scrolling.
This way you can save some memory using the views recycling mechanism. Using the detailed notification mechanisms (like item moved/deleted) you even can add some animations if the objects are moving.
In addition to a proposed solution like evrencoskun/TableView, I would suggest to glance on how the way how GridLayoutManger
works overall, here is the first post out of three in a relatively deep review of how the RecyclerView
and its LayoutManager
s work`, so you could tailor more lightweight solution for your particular case. There is a simple demo app, "Fixed two-way list" with "Large Grid" option may give you some idea of what will be built. You will need to extend it to work with infinite lists, but it should be simpler when you understand the internals.
2D engine
If the idea is to have some graphics over the tiles with arbitrary sizes and the feature is core for your app, it might be a good idea to consider using some 2d engine like libdx. They have many examples how to use it but of course it will cost you some storage and time to learn it: libgdx wike
Own solution
If neither of both suits your needs, I think, you will have to find your own solution from scratch. Don't forget to optimize it, as every infinite thing in Android, especially bound to graphics, may easily lead to Out of memory errors.
add a comment |
Depending on your requirements, it looks like either a table-like RecyclerView with infinite scrolling either some 2d game engine (in case if it's worth to bring it for this feature) might be an optimal solution for you.
RecyclerView
In case if you just want to store some objects (graphical or not - does not really matter, if you can pack them to the cells), you can use some kind of RecyclerView adapter with an extension for boundless scrolling.
This way you can save some memory using the views recycling mechanism. Using the detailed notification mechanisms (like item moved/deleted) you even can add some animations if the objects are moving.
In addition to a proposed solution like evrencoskun/TableView, I would suggest to glance on how the way how GridLayoutManger
works overall, here is the first post out of three in a relatively deep review of how the RecyclerView
and its LayoutManager
s work`, so you could tailor more lightweight solution for your particular case. There is a simple demo app, "Fixed two-way list" with "Large Grid" option may give you some idea of what will be built. You will need to extend it to work with infinite lists, but it should be simpler when you understand the internals.
2D engine
If the idea is to have some graphics over the tiles with arbitrary sizes and the feature is core for your app, it might be a good idea to consider using some 2d engine like libdx. They have many examples how to use it but of course it will cost you some storage and time to learn it: libgdx wike
Own solution
If neither of both suits your needs, I think, you will have to find your own solution from scratch. Don't forget to optimize it, as every infinite thing in Android, especially bound to graphics, may easily lead to Out of memory errors.
add a comment |
Depending on your requirements, it looks like either a table-like RecyclerView with infinite scrolling either some 2d game engine (in case if it's worth to bring it for this feature) might be an optimal solution for you.
RecyclerView
In case if you just want to store some objects (graphical or not - does not really matter, if you can pack them to the cells), you can use some kind of RecyclerView adapter with an extension for boundless scrolling.
This way you can save some memory using the views recycling mechanism. Using the detailed notification mechanisms (like item moved/deleted) you even can add some animations if the objects are moving.
In addition to a proposed solution like evrencoskun/TableView, I would suggest to glance on how the way how GridLayoutManger
works overall, here is the first post out of three in a relatively deep review of how the RecyclerView
and its LayoutManager
s work`, so you could tailor more lightweight solution for your particular case. There is a simple demo app, "Fixed two-way list" with "Large Grid" option may give you some idea of what will be built. You will need to extend it to work with infinite lists, but it should be simpler when you understand the internals.
2D engine
If the idea is to have some graphics over the tiles with arbitrary sizes and the feature is core for your app, it might be a good idea to consider using some 2d engine like libdx. They have many examples how to use it but of course it will cost you some storage and time to learn it: libgdx wike
Own solution
If neither of both suits your needs, I think, you will have to find your own solution from scratch. Don't forget to optimize it, as every infinite thing in Android, especially bound to graphics, may easily lead to Out of memory errors.
Depending on your requirements, it looks like either a table-like RecyclerView with infinite scrolling either some 2d game engine (in case if it's worth to bring it for this feature) might be an optimal solution for you.
RecyclerView
In case if you just want to store some objects (graphical or not - does not really matter, if you can pack them to the cells), you can use some kind of RecyclerView adapter with an extension for boundless scrolling.
This way you can save some memory using the views recycling mechanism. Using the detailed notification mechanisms (like item moved/deleted) you even can add some animations if the objects are moving.
In addition to a proposed solution like evrencoskun/TableView, I would suggest to glance on how the way how GridLayoutManger
works overall, here is the first post out of three in a relatively deep review of how the RecyclerView
and its LayoutManager
s work`, so you could tailor more lightweight solution for your particular case. There is a simple demo app, "Fixed two-way list" with "Large Grid" option may give you some idea of what will be built. You will need to extend it to work with infinite lists, but it should be simpler when you understand the internals.
2D engine
If the idea is to have some graphics over the tiles with arbitrary sizes and the feature is core for your app, it might be a good idea to consider using some 2d engine like libdx. They have many examples how to use it but of course it will cost you some storage and time to learn it: libgdx wike
Own solution
If neither of both suits your needs, I think, you will have to find your own solution from scratch. Don't forget to optimize it, as every infinite thing in Android, especially bound to graphics, may easily lead to Out of memory errors.
answered Jan 11 at 3:04


GaketGaket
2,72912046
2,72912046
add a comment |
add a comment |
I would like to suggest this evrencoskun/TableView.
It allows you to scroll both horizontally and vertically.
<com.evrencoskun.tableview.TableView
android:id="@+id/content_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Thank you! It looks very interesting, I will definitely check it out!
– BanzaiTokyo
Jan 2 at 15:19
it looks like the table is not quite what I need. I need a grid to place graphic objects. I will see if I can come up with a custom component.
– BanzaiTokyo
Jan 3 at 21:46
add a comment |
I would like to suggest this evrencoskun/TableView.
It allows you to scroll both horizontally and vertically.
<com.evrencoskun.tableview.TableView
android:id="@+id/content_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Thank you! It looks very interesting, I will definitely check it out!
– BanzaiTokyo
Jan 2 at 15:19
it looks like the table is not quite what I need. I need a grid to place graphic objects. I will see if I can come up with a custom component.
– BanzaiTokyo
Jan 3 at 21:46
add a comment |
I would like to suggest this evrencoskun/TableView.
It allows you to scroll both horizontally and vertically.
<com.evrencoskun.tableview.TableView
android:id="@+id/content_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
I would like to suggest this evrencoskun/TableView.
It allows you to scroll both horizontally and vertically.
<com.evrencoskun.tableview.TableView
android:id="@+id/content_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
answered Jan 2 at 15:15
May Rest in PeaceMay Rest in Peace
64411119
64411119
Thank you! It looks very interesting, I will definitely check it out!
– BanzaiTokyo
Jan 2 at 15:19
it looks like the table is not quite what I need. I need a grid to place graphic objects. I will see if I can come up with a custom component.
– BanzaiTokyo
Jan 3 at 21:46
add a comment |
Thank you! It looks very interesting, I will definitely check it out!
– BanzaiTokyo
Jan 2 at 15:19
it looks like the table is not quite what I need. I need a grid to place graphic objects. I will see if I can come up with a custom component.
– BanzaiTokyo
Jan 3 at 21:46
Thank you! It looks very interesting, I will definitely check it out!
– BanzaiTokyo
Jan 2 at 15:19
Thank you! It looks very interesting, I will definitely check it out!
– BanzaiTokyo
Jan 2 at 15:19
it looks like the table is not quite what I need. I need a grid to place graphic objects. I will see if I can come up with a custom component.
– BanzaiTokyo
Jan 3 at 21:46
it looks like the table is not quite what I need. I need a grid to place graphic objects. I will see if I can come up with a custom component.
– BanzaiTokyo
Jan 3 at 21:46
add a comment |
might this link will be helpful for you
https://github.com/jess-anders/two-way-gridview
<?xml version="1.0" encoding="utf-8"?>
<com.jess.ui.TwoWayGridView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#E8E8E8"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:cacheColorHint="#E8E8E8"
app:columnWidth="80dp"
app:rowHeight="80dp"
app:numColumns="auto_fit"
app:numRows="auto_fit"
app:verticalSpacing="16dp"
app:horizontalSpacing="16dp"
app:stretchMode="spacingWidthUniform"
app:scrollDirectionPortrait="vertical"
app:scrollDirectionLandscape="horizontal"
app:gravity="center"/>
Thanks! I will check it out. But isn't this widget made for scrolling vertically OR horisontally? Does it do both?
– BanzaiTokyo
Jan 2 at 13:04
why does it work?please either highlight relevant sections or explain the snippet
– kkarakk
Jan 9 at 8:13
add a comment |
might this link will be helpful for you
https://github.com/jess-anders/two-way-gridview
<?xml version="1.0" encoding="utf-8"?>
<com.jess.ui.TwoWayGridView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#E8E8E8"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:cacheColorHint="#E8E8E8"
app:columnWidth="80dp"
app:rowHeight="80dp"
app:numColumns="auto_fit"
app:numRows="auto_fit"
app:verticalSpacing="16dp"
app:horizontalSpacing="16dp"
app:stretchMode="spacingWidthUniform"
app:scrollDirectionPortrait="vertical"
app:scrollDirectionLandscape="horizontal"
app:gravity="center"/>
Thanks! I will check it out. But isn't this widget made for scrolling vertically OR horisontally? Does it do both?
– BanzaiTokyo
Jan 2 at 13:04
why does it work?please either highlight relevant sections or explain the snippet
– kkarakk
Jan 9 at 8:13
add a comment |
might this link will be helpful for you
https://github.com/jess-anders/two-way-gridview
<?xml version="1.0" encoding="utf-8"?>
<com.jess.ui.TwoWayGridView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#E8E8E8"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:cacheColorHint="#E8E8E8"
app:columnWidth="80dp"
app:rowHeight="80dp"
app:numColumns="auto_fit"
app:numRows="auto_fit"
app:verticalSpacing="16dp"
app:horizontalSpacing="16dp"
app:stretchMode="spacingWidthUniform"
app:scrollDirectionPortrait="vertical"
app:scrollDirectionLandscape="horizontal"
app:gravity="center"/>
might this link will be helpful for you
https://github.com/jess-anders/two-way-gridview
<?xml version="1.0" encoding="utf-8"?>
<com.jess.ui.TwoWayGridView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#E8E8E8"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:cacheColorHint="#E8E8E8"
app:columnWidth="80dp"
app:rowHeight="80dp"
app:numColumns="auto_fit"
app:numRows="auto_fit"
app:verticalSpacing="16dp"
app:horizontalSpacing="16dp"
app:stretchMode="spacingWidthUniform"
app:scrollDirectionPortrait="vertical"
app:scrollDirectionLandscape="horizontal"
app:gravity="center"/>
answered Jan 2 at 12:56


RahulRahul
9181522
9181522
Thanks! I will check it out. But isn't this widget made for scrolling vertically OR horisontally? Does it do both?
– BanzaiTokyo
Jan 2 at 13:04
why does it work?please either highlight relevant sections or explain the snippet
– kkarakk
Jan 9 at 8:13
add a comment |
Thanks! I will check it out. But isn't this widget made for scrolling vertically OR horisontally? Does it do both?
– BanzaiTokyo
Jan 2 at 13:04
why does it work?please either highlight relevant sections or explain the snippet
– kkarakk
Jan 9 at 8:13
Thanks! I will check it out. But isn't this widget made for scrolling vertically OR horisontally? Does it do both?
– BanzaiTokyo
Jan 2 at 13:04
Thanks! I will check it out. But isn't this widget made for scrolling vertically OR horisontally? Does it do both?
– BanzaiTokyo
Jan 2 at 13:04
why does it work?please either highlight relevant sections or explain the snippet
– kkarakk
Jan 9 at 8:13
why does it work?please either highlight relevant sections or explain the snippet
– kkarakk
Jan 9 at 8:13
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54006399%2f2-dimensional-scroll-for-a-grid-in-android%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Could you add some more requirements, please? What should be on the grid? How often it will be updated? Is it about putting some graphical elements there and then just scrolling or is does it require to move that elements to different positions too?
– Gaket
Jan 11 at 2:09
try this stackoverflow.com/a/16303262/6587502
– Ashutosh Sagar
Jan 11 at 9:12