Android之view虚线

使用环境:

偶尔会用到,一根虚线………………

使用方法: 

小技巧讲述:  view的height一定要比shape中line的height高!  第二,shape中要有


上代码:

xml version="1.0" encoding="utf-8"?>
xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="@dimen/two"
    android:background="@drawable/dashfive"
    android:layerType="software"
    />

dashfive/drawablw

xml version="1.0" encoding="utf-8"?>
xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line">
            android:width="1dp"
        android:color="#999999"
        android:dashGap="5dp"
        android:dashWidth="5dp" />
    android:height="@dimen/one"/>

至于xml文件是怎么写的,平时一根线怎么写就怎么写,但是要加一条属性:

android:layerType="software"  

出来的效果是:


亲测,AS版本3.0,Android版本5.1,管用!


你可能感兴趣的:(日记)