Android Horizontal LinearLayout - Wrap Elements

房东的猫 提交于 2019-11-26 14:11:58

问题


I have a horizontal linear layout that contains textviews generated dynamically, the problem I'm experiencing is that the textviews are squeezed (see image below) if too many of them are added. How would I go about wrapping the linearlayout so that the textviews are printed on the next line?


回答1:


LinearLayout cant help with this. Instead you will have make your own Layout as mentioned in this http://nishantvnair.wordpress.com/2010/09/28/flowlayout-in-android/ or incorporate the same approach as of this Android - LinearLayout Horizontal with wrapping children




回答2:


This project is nice because you can just add the Gradle compile directive for the project, and be able to use the FlowLayout in the Xml from there. No need to copy in Java files

https://github.com/ApmeM/android-flowlayout




回答3:


FlexboxLayout is a library project which brings the similar capabilities of CSS Flexible Box Layout Module to Android.

https://github.com/google/flexbox-layout

Similar question:

Line-breaking widget layout for Android



来源:https://stackoverflow.com/questions/14528381/android-horizontal-linearlayout-wrap-elements

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