AndroidDesign
Summary: Author: 张亚飞 | Read Time: 1 minute read | Published: 2017-02-12
Filed under
—
Categories:
Linux
—
Tags:
Note,
Android Design 相关
首先看一下要怎么实现水平的虚分割线: 在 drawable 文件下建立 line_dotted_horizontal.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:color="#C7B299"
android:dashGap="6px"
android:dashWidth="6px"/>
</shape>
按如下方式引用:
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@drawable/line_dotted_horizontal"
android:layerType="software"/>
注意:需要添加 android:layerType=“software” 否则在有些设备上仍然显示实线
垂直的虚线
drawable 下新建 line_dotted_vertical.xml
填上参考一下
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="-300dp"
android:right="-300dp">
<rotate
android:drawable="@drawable/line_dotted_horizontal"
android:fromDegrees="90"
android:toDegrees="90"
android:visible="true"/>
</item>
</layer-list>
或者
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/line_dotted_horizontal"
android:fromDegrees="90"
android:toDegrees="90"/>
参考列表
Comments