版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_32961877/article/details/85275393
view 实现虚线,不显示,搜了一圈,都是说什么 view 高度要大于 shape 定义的 高度,
现 总结一下 :
这样写,关键点 :android:width="1dp" 这个代表的才是 shape的 高度,
而 <size android:height="2dp"/> 这个高度属性 无所谓,删掉!
android:shape="line" 是 让绘制出线条,不然是个 容器的背景 四条线 都有
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <stroke android:width="1dp" android:color="#dedede" android:dashWidth="5dp" android:dashGap="5dp" /> <size android:height="2dp"/> </shape>布局里 引用:layout_height 的值 大于 shape 里边的 width 就好了 <View android:layout_width="match_parent" android:layout_height="2dp" android:layout_marginLeft="20dp" android:layout_marginTop="5dp" android:layout_marginRight="20dp" android:background="#dedede" android:layerType="software" />