Android LinearLayout 分割线
Android 大约 2114 字原生 divider
<LinearLayout
android:divider="?android:dividerHorizontal"
/>
自定义 divider
showDividers
是分隔线的显示位置,beginning
、middle
、end
分别代表显示在开始位置,中间,末尾。
<LinearLayout
android:id="@+id/km_calllog_root_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:divider="@drawable/km_calllog_divider"
android:orientation="vertical"
android:showDividers="middle"/>
还有dividerPadding
属性这里没有用到,意思很明确给divider
添加padding
。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:width="1dp"
android:height="1dp"/>
<solid android:color="#e1e1e1"/>
</shape>
设置一边距离的padding
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="20dp">
<shape
android:shape="rectangle">
<size
android:width="1dp"
android:height="1dp"/>
<solid android:color="#F2F2F2"/>
</shape>
</inset>
InsetDrawable
定义这个drawable为InsetDrawable,必须作为根节点。 - 属性:xmlns:android
String类型。必须的,定义XML文件的命名空间,必须是 "http://schemas.android.com/apk/res/android". - android:drawable
Drawable 资源 。必须的。引用一个drawable资源 - android:insetTop
尺寸。与顶部的距离。可以使一个尺寸值,或者一个尺寸的资源。 - android:insetRight
尺寸。与右边的距离。可以使一个尺寸值,或者一个尺寸的资源。 - android:insetBottom
尺寸。与底部的距离。可以使一个尺寸值,或者一个尺寸的资源。 - android:insetLeft
尺寸。与左边的距离。可以使一个尺寸值,或者一个尺寸的资源。
示例
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/background"
android:insetTop="10dp"
android:insetLeft="10dp" />
<?xml version="1.0" encoding="utf-8"?>
<inset
xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/drawable_resource"
android:insetTop="dimension"
android:insetRight="dimension"
android:insetBottom="dimension"
android:insetLeft="dimension" />
阅读 4190 · 发布于 2019-04-09
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
PostgreSQL 修改字段属性阅读 1819
-
Redis 使用 hash tag 插入到同一个哈希槽阅读 4000
-
PostgreSQL 对数组字段增删改查阅读 4833
-
Elasticsearch 使用 RESTful API 进行通信阅读 1432
-
Linux 之 CentOS 安装 JDK 及 JRE阅读 2441
-
Java 中类的变量、代码块、构造方法加载的顺序阅读 1159
-
网页文字不能复制解决方法阅读 2335
-
Linux LC_ALL=C 的作用阅读 522
-
IDEA 去除 Unchecked cast from Object to 提示阅读 3232
-
Kubernetes kubectl top 命令报 error: Metrics API not available阅读 745