如果当前行中没有空格,则用换行符包装其子级的ViewGroup [英] ViewGroup that wrap its children with line breaking if there is no space in the current line
本文介绍了如果当前行中没有空格,则用换行符包装其子级的ViewGroup的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这里尝试过旧的解决方案:
Line-
I have tried old solutions here: Line-breaking widget layout for Android
是否有新的适当方法来实现此功能?
Is there a new proper way to implement this functionality?
推荐答案
Google提供的新的 FlexboxLayout 库即可。
New FlexboxLayout library by Google do this.
<com.google.android.flexbox.FlexboxLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:flexWrap="wrap"
app:alignItems="stretch"
app:alignContent="stretch" >
<TextView
android:layout_width="120dp"
android:layout_height="80dp" />
<TextView
android:layout_width="80dp"
android:layout_height="80dp" />
<TextView
android:layout_width="160dp"
android:layout_height="80dp" />
</com.google.android.flexbox.FlexboxLayout>
这篇关于如果当前行中没有空格,则用换行符包装其子级的ViewGroup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文