GridView with variable width items

巧了我就是萌 提交于 2019-12-08 13:35:38

问题


I need to achieve a behavior like the last.fm tag cloud on Android.

This means: my items have android:layout_width="wrap_content", and I need to display horizontally until an item doesn't fit horizontally on the View, which will be the first item of the next row. I'd also like to populate the view with a ListAdapter.

Writing such View seems overly complicated. Is there any library project that achieves this effect?


回答1:


What you're looking for is a FlowLayout. It doesn't exist natively in Android, but Romain Guy (a former Android engineer) gave a talk showing a quick implementation, and there are also several libraries available that you could use, or easily spin your own.

https://github.com/ApmeM/android-flowlayout
https://github.com/blazsolar/FlowLayout
http://nishantvnair.wordpress.com/2010/09/28/flowlayout-in-android/
http://hzqtc.github.io/2013/12/android-custom-layout-flowlayout.html



来源:https://stackoverflow.com/questions/21342518/gridview-with-variable-width-items

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