ViewGroup that wrap its children with line breakin

2019-09-10 07:30发布

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

Is there a new proper way to implement this functionality?

1条回答
做自己的国王
2楼-- · 2019-09-10 08:08

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>
查看更多
登录 后发表回答