安卓开发

安卓流式布局FlowLayout样例

2020-10-20  本文已影响0人  蓝不蓝编程

用途

让布局里的控件自动换行

效果图

使用方法

  1. 添加依赖
implementation 'com.nex3z:flow-layout:1.3.1'
  1. 代码
<com.nex3z.flowlayout.FlowLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:background="@drawable/shape_rec_blue"
        android:padding="10dp"
        android:text="@string/test" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:background="@drawable/shape_rec_blue"
        android:padding="10dp"
        android:text="@string/test" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:background="@drawable/shape_rec_blue"
        android:padding="10dp"
        android:text="@string/test" />
</com.nex3z.flowlayout.FlowLayout>

完整源代码

https://gitee.com/cxyzy1/flow-layout-demo

上一篇 下一篇

猜你喜欢

热点阅读