使用shape来绘制虚线¶
需要stroke设置android:dashGap属性。
shape_dash_line_uf.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<size android:height="1dp" />
<stroke
android:width="1dp"
android:color="#474c57"
android:dashWidth="1dp"
android:dashGap="2dp" />
</shape>
关掉activity的硬件加速android:hardwareAccelerated="false",否则会显示一条直线。
<activity
android:name="com.rustfisher.basic4.UserFeedbackAct"
android:hardwareAccelerated="false"
android:screenOrientation="portrait">
</activity>
layout中使用。把shape设置为背景。并且View的高度设置为0dp。