java Android Horizontal LinearLayout - 包裹元素
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14528381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Horizontal LinearLayout - Wrap Elements
提问by Anton
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?
我有一个包含动态生成的文本视图的水平线性布局,我遇到的问题是如果添加太多文本视图,文本视图会被挤压(见下图)。我将如何包装线性布局以便文本视图打印在下一行?
采纳答案by Avinazz
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
LinearLayout 对此无能为力。相反,您将按照http://nishantvnair.wordpress.com/2010/09/28/flowlayout-in-android/ 中所述制作自己的布局,或者采用与此Android相同的方法- LinearLayout Horizontal with wrapping children
回答by Darush
FlexboxLayout is a library project which brings the similar capabilities of CSS Flexible Box Layout Module to Android.
FlexboxLayout 是一个库项目,它将 CSS 弹性框布局模块的类似功能引入 Android。
https://github.com/google/flexbox-layout
https://github.com/google/flexbox-layout
Similar question:
类似问题:
回答by Gene Bo
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
这个项目很好,因为您可以为项目添加 Gradle 编译指令,并能够从那里使用 Xml 中的 FlowLayout。无需复制到 Java 文件中