ViewGroup that wrap its children with line breaking if there is no space in the current line

 ̄綄美尐妖づ 提交于 2019-12-12 03:24:11

问题


I have tried old solutions here: Line-breaking widget layout for Android

Is there a new proper way to implement this functionality?


回答1:


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>


来源:https://stackoverflow.com/questions/37147677/viewgroup-that-wrap-its-children-with-line-breaking-if-there-is-no-space-in-the

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