Android 绘制虚线
AndroidView
简单需求
先来看看这么一个需求
水平虚线
如果需要完成上面的水平虚线,可以这样处理。声明shape,其中dashGap是虚线的间隔宽度,dashWidth是实线的间隔宽度,stroke翻译过来是名词,画
android:shape="line">
android:width="1dp"
android:dashGap="3dp"
android:dashWidth="3dp"
android:color="#ffececec"/>
然后可以在layout文件中直接使用
android:layout_width="match_parent"
android:layout_height="2dp"
android:contentDescription="@string/contentDescription"
android:layerType="software"
android:background="@drawable/dash_line"/>
竖直虚线
按照上面