Need a ViewGroup(Customised) for Different Rowheights with two columns in Android

做~自己de王妃 提交于 2019-12-13 17:14:36

问题


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.


回答1:


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/



来源:https://stackoverflow.com/questions/14641920/need-a-viewgroupcustomised-for-different-rowheights-with-two-columns-in-androi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!