项目中遇到通过inflate动态添加控件,不同于一个一个String充满后会自动换行,就找到了这个很好用的库。
先说效果图:
废话不多,直接上依赖:
compile 'cn.wolfspider:autowraplinelayout:1.0.1'
添加下面布局到xml:
<cn.wolfspider.autowraplinelayout.AutoWrapLineLayout android:id="@+id/auto_wrap_line_layout" android:layout_width="match_parent" android:layout_height="match_parent" autoWrapLineLayout:verticalGap="1dp" autoWrapLineLayout:horizontalGap="1dp" autoWrapLineLayout:fillMode = "0"> </cn.wolfspider.autowraplinelayout.AutoWrapLineLayout>
该有的都有了,附上github的地址: