您的位置:首页 > 其它

第三方开源库:流式布局:FlowLayout

2017-02-20 19:03 483 查看

FlowLayout

github:https://github.com/nex3z/FlowLayout

使用的时候把子view添加到FlowLayout中。

flowLayout.addView(tv);




属性

属性说明
app:childSpacing=”auto”子布局的间隔
app:childSpacingForLastRow=”align”最后一行子布局
app:rowSpacing=”8dp”行间距
app:rtl=”true”

xml:

<com.nex3z.flowlayout.FlowLayout
android:id="@+id/flowLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:childSpacing="auto"
app:childSpacingForLastRow="align"
app:rowSpacing="8dp"
app:rtl="true"/>


Java

flowLayout = (FlowLayout) findViewById(R.id.flowLayout);
array = getResources().getStringArray(R.array.lorem_ipsum);
for (int i = 0; i < array.length; i++) {
TextView tv = new TextView(this);
tv.setText(array[i]);
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,16);
tv.setPadding(30,10,30,10);
tv.setBackgroundResource(R.drawable.tv_bg_shape);
flowLayout.addView(tv);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: