Android第三方库——FlowLayout
来源:互联网 发布:meanshift算法流程图 编辑:程序博客网 时间:2024/06/06 14:20
一、添加依赖
compile 'com.nex3z:flow-layout:0.1.2'
二、使用
1.在Xml中声明:
<com.nex3z.flowlayout.FlowLayout android:id="@+id/flow_layout" android:layout_width="match_parent" android:layout_height="match_parent" app:childSpacing="6dp" app:rowSpacing="8dp" /> <!--自定义属性--> <!-- flow = "true" 流式布局 childSpacing:子控件之间的距离 "auto" rowSpacing:行间距 childSpacingForLastRow:子控件最后一行的间距 rtl = "true" 一行从右往左一次排列 -->
2.给子控件设置shape
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#ff00ff"/> <corners android:radius="25dp"/> <stroke android:width="1dp" android:color="#3799f4"/></shape>
3.java代码中动态添加子控件
private void getList(List<ListBean> list) { mFlowLayout = (FlowLayout) findViewById(R.id.flow_layout); /** * 根据集合动态生成控件TextView */ for (final ListBean b: list) { TextView textView = new TextView(this); textView.setPadding(16,8,16,8); textView.setText(b.getName()); textView.setTextSize(16); textView.setBackgroundResource(R.drawable.s); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Snackbar.make(v,b.getTitle(),Snackbar.LENGTH_SHORT).show(); } }); mFlowLayout.addView(textView); } }
三、效果图
0 0
- Android第三方库——FlowLayout
- Android第三方库——Toasty
- Android 第三方库
- android第三方库
- Android第三方库
- Android第三方库
- Android第三方库
- android调用第三方库——第一篇
- Android Studio 导入第三方库——*.jar包
- Android第三方库——强大BaseRecyclerViewAdapterHelper
- Android-Iconics——第三方Iconfont库,Excelent
- Android权限处理——第三方库easypermissions使用
- Android第三方库——SpinKitView样式
- Android——第三方QQ登录
- Android—(第三方百度地图)
- android调用第三方库——第四篇——调用多个第三方库
- android调用第三方库——第四篇——调用多个第三方库
- android 自定义第三方库
- python
- 第三章数组和字符串下
- CS0428号错误是什么
- 白盒测试方法
- svn检出的时候报 Unable to connect to a repository at URL错误
- Android第三方库——FlowLayout
- 归一化
- 动态设置Button的透明度文字不显示问题
- 自己的学习和时间安排
- 为什么Android系统要比ios卡
- 02.JUC 锁
- 105. Construct Binary Tree from Preorder and Inorder Traversal
- textfield 输入之后button变色 监听 (IOS 根据输入值改变button颜色)
- Apache服务器配置虚拟主机