【问题标题】:ViewGroup that wrap its children with line breaking if there is no space in the current line如果当前行中没有空格,则使用换行符包装其子项的 ViewGroup
【发布时间】:2016-05-10 19:49:09
【问题描述】:

我在这里尝试过旧的解决方案: Line-breaking widget layout for Android

是否有新的正确方法来实现此功能?

【问题讨论】:

    标签: android android-viewgroup


    【解决方案1】:

    Google 的新 FlexboxLayout 库执行此操作。

    <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多