(转)LinearLayoutCompat添加分割线----divider
2015-12-23 15:24
741 查看
Android Material Design 扩展支持包中的LinearLayoutCompat是过去的LinearLayout的扩展,可以为此布局中功德子View之间添加分割线divider。
其中比较关键的地方有两点:
(1)app:showDividers="beginning|middle|end"属性。
beginning,middle,end属性值分别指明将在何处添加分割线。
beginning表示从该LinearLayoutCompat布局的最顶一个子view的顶部开始。
middle表示在此LinearLayoutCompat布局内的子view之间添加。
end表示在此LinearLayoutCompat最后一个子view的底部添加分割线。
(2)app:divider="@drawable/line"
LinearLayoutCompat添加分割线需要为此分割线定义一个shape。
现给出一个例子加以说明。
位于drawable目录下的line.xml文件(定义的分割线属性)
其中比较关键的地方有两点:
(1)app:showDividers="beginning|middle|end"属性。
beginning,middle,end属性值分别指明将在何处添加分割线。
beginning表示从该LinearLayoutCompat布局的最顶一个子view的顶部开始。
middle表示在此LinearLayoutCompat布局内的子view之间添加。
end表示在此LinearLayoutCompat最后一个子view的底部添加分割线。
(2)app:divider="@drawable/line"
LinearLayoutCompat添加分割线需要为此分割线定义一个shape。
现给出一个例子加以说明。
<android.support.v7.widget.LinearLayoutCompat 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" android:padding="20dip" android:orientation="vertical" app:divider="@drawable/line" app:dividerPadding="5dp" app:showDividers="beginning|middle|end" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="CSDN Zhang Phil" /> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:src="@drawable/ic_launcher"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="CSDN Zhang Phil" /> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:src="@drawable/ic_launcher"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="CSDN Zhang Phil" /> </android.support.v7.widget.LinearLayoutCompat>
位于drawable目录下的line.xml文件(定义的分割线属性)
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@android:color/black" /> <!-- 分割线的高度 --> <size android:height="3dip" /> </shape>
相关文章推荐
- RMAN常用命令汇总
- 基本套接字编程(1) -- tcp篇
- ubuntu15.10下编译安装wine1.8 rc4
- 自动发布系统
- 简单 js fileUpload控件
- Groovy的方法、闭包语法,接口的实现
- 性能2
- 成功将DM8168作为服务器端总结
- 有趣的Autolayout示例2-Masonry实现
- Android VideoView简单播放视频
- Java实现HTML转PDF的总结
- <iOS>ARC下需要注意的内存管理
- 进入docker容器之nsenter脚本
- python os模块 常用命令
- 如何去阅读Android的崩溃日志(crash log)和栈轨迹(stack trace)
- 高职组:2、马虎的算式
- Mac必备软件推荐
- ViewPager设置自适应
- 猫眼产品分析
- 集合类说明及区别