画虚线无效问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wang_yong_hui_1234/article/details/83900976

画一条虚线,先再line_shape.xml中定义

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line">

    <!--线宽为dashWith,线之间空隙dashGap,dashGap=0dp时,是实线 -->
    <stroke
        android:width="1dp"
        android:color="@android:color/holo_red_dark"
        android:dashGap="7dp"
        android:dashWidth="8dp" />
</shape>

在页面中引用

 <View
        android:id="@+id/import_recycler_item_line"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/imaginary_line_shape"
        android:layerType="software" />

需要注意的是 android:layerType=“software” ,如果不加是不显示的

猜你喜欢

转载自blog.csdn.net/wang_yong_hui_1234/article/details/83900976