小技巧:虚线分割线

//使用方式:
   <View style="@style/dash_line"/>
//定义style:
   <style name="dash_line">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layerType">software</item>//1.注意要加上这句。
        <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>

猜你喜欢

转载自blog.csdn.net/qq_17827919/article/details/76460778