美文网首页
Android shape 画虚线

Android shape 画虚线

作者: _发强 | 来源:发表于2018-08-15 17:42 被阅读0次

利用 Android shape 标签绘制一条虚线

Step 1 :

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line">

    <stroke
        android:width="@dimen/dp_1"
        android:color="@color/c_525a6d"
        android:dashGap="@dimen/dp_2"
        android:dashWidth="@dimen/dp_2" />
</shape>

Step 2 :

<View
            android:layout_width="match_parent"
            android:layout_height="@dimen/dp_2"
            android:layout_marginLeft="@dimen/dp_15"
            android:layout_marginRight="@dimen/dp_15"
            android:layout_marginTop="@dimen/dp_25"
            android:background="@drawable/shape_dash_line_525a6d"
            android:layerType="software" />

注意: 需要添加 layerType 标签,否则为实线。

相关文章

网友评论

      本文标题:Android shape 画虚线

      本文链接:https://www.haomeiwen.com/subject/vegwbftx.html