I have infinite number of items. Want to display them in two columns as a GridView with lazy loading. I tried it with GridView, which is displaying all items in a row with the same height. But want it to be adjusted according to the item height as in the attached image. If anyone have any idea or any of u have implemented this with some customized View. Please share it across. Thanx in advance.
Need a ViewGroup(Customised) for Different Rowheights with two columns in Android
Asked Answered
Where does #3 go in this picture? –
Crissy
Nice observation Brian Attwell. But, Don't worry bout those numbers(#s). The concern is about Layout. –
Speedboat
New answer
Look at the RecyclerView
. The RecyclerView
replaces ListView
and is designed to be flexible enough to support your use case.
RecyclerView
is a part of the support library, added in android L. So it should work on any version of Android. But beware, at the time of this writing, android L is in preview.
Original answer
There is an experimental class in the Android source code called StaggeredGridView
that does what you want. It is contained in frameworks/ex/widgets/
folder.
It isn't finished yet. However, some people have built working prototypes based off it. Ex: http://www.androidviews.net/2013/01/pinterest-like-adapterview/
Thanx bro. I tried StaggeredGridView. Its giving compile time errors. because my app's min sdk version is 10(Gingerbread). So its not finding some classes, That are there in StaggeredGridView(such as private final ScrollerCompat mScroller;). I tried including support libraries and all. But still of no use. Please lemme know, are there any hacks for this. Thanks in advance. –
Speedboat
I havent heard of any jacks for GB. –
Crissy
@Brian Thanks for StaggeredGridView suggestion I tried this but it creates problem at time of Orientation change. Do you have any suggestion about this? Thanks. –
Carducci
© 2022 - 2024 — McMap. All rights reserved.