Android Horizontal LinearLayout - Wrap Elements

2019-01-09 02:39发布

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?

enter image description here

3条回答
Deceive 欺骗
2楼-- · 2019-01-09 03:30

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

查看更多
戒情不戒烟
3楼-- · 2019-01-09 03:33

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

查看更多
成全新的幸福
4楼-- · 2019-01-09 03:41

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

查看更多
登录 后发表回答