<View style="@style/dash_line"/>
//定义style:
<style name="dash_line">
<item name="android:layout_width">match_parent</item>
<item name="android:layerType">software</item
<item name="android:layout_height">@dimen/px4</item>2.view 的高度要大于 shape 的stroke 宽度,注意这两点就可以正常显示了。
<item name="android:background">@drawable/dash_line_shape</item>
</style>
//定义shape:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="@dimen/px2"
android:color="#979797"
android:dashGap="@dimen/px8"
android:dashWidth="@dimen/px5" />
</shape>