There are certain advantages to GridView besides the built-in scrolling. For example, a sequential dynamic cell layout that will expand and contract based on the data you pass into it. Therefore, when people say that itβs not good to want such functionality, I think this is wrong, because you can want a dynamic grid of images (views) inside the scroll, but you want the whole scrollable view to contain other things, and not just the cell grid.
Now, here is how you can do it. Check the answer here . This is the extensible GridView height that you will want to import / create in your project. This basically means that as you add more elements to the GridView, it will simply increase its height, as opposed to saving its height and using scroll. This is exactly what you want.
Once you have the ExpandableHeightGridView project in your project, go to your XML layout where you want the GridView. Then you can do something like this (to rephrase):
<ScrollView ...> <RelativeLayout ...> <com.example.ExpandableHeightGridView ... /> <other view items /> </RelativeLayout> </ScrollView>
Then, in your activity where you install the GridView adapter, you want you to install it for the extension. So:
ExpandableHeightGridView gridView = (ExpandableHeightGridView) findViewById(R.id.myId); gridView.setAdapter(yourAdapter); gridView.setExpanded(true);
The reason you want this extensible GridView is because the fact that the standard GridView is not extensible causes it to hang. It sticks to a certain height, and then when the number of elements fills it beyond its visibility, it becomes scrollable. Now, with this, your GridView will always expand its height to match the content inside it, so it never allowed it to enter its scroll mode. This allows you to use it inside a ScrollView and use other view elements above or below it in a ScrollView and scroll through them all.
This will give you the result you are looking for. Let me know if you have any questions.
dennisdrew Oct 12 2018-12-12T00: 12Z
source share