an...">
美文网首页
Android中绘制虚线

Android中绘制虚线

作者: XiaoXred | 来源:发表于2020-11-03 11:34 被阅读0次

1.利用shape绘制

<?xml version="1.0" encoding="utf-8"?>

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

    android:shape="line">

        android:width="3px"

        android:color="#CB9C1F"

        android:dashWidth="10px"

        android:dashGap="10px" />

</shape>

下面对属性进行一下介绍:

width:线段的高度 

color:线段的颜色 

dashWidth:线段宽度 

dashGap:线段之间间隔宽度

2.然后在布局文件中使用如下:

<View

    android:layout_width="match_parent"

    android:layout_height="5dp"

    android:layout_marginStart="15dp"

    android:layout_marginTop="10dp"

    android:layout_marginEnd="15dp"

    android:background="@drawable/dash_view_shape"

    android:layerType="software" />

相关文章

网友评论

      本文标题:Android中绘制虚线

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