Android 实现虚线,实线
虚线
实线
虚线
实现的方法是比较简单的,不多说,直接看代码.
android:shape="line">
android:width="1dp"
android:dashWidth="10dp"
android:color="#f84d4d"
android:dashGap="4dp"/>
这里说明一下:
dashWith 是虚线的长度
dashGap 是虚线之间的宽度
color 是虚线的颜色
但是,在实时预览里面能看到虚线了,但是程序跑起来之后,发现仍然是实线.这里还要在清单文件中,把硬件加速给禁掉.
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:hardwareAccelerated="false" >
android:hardwareAccelerated=”false” 硬件加速设为false
这样就实现了从xml中实现虚线的方法.
实线
这个是比较简单的.根据上面的虚线来设置就行.
android:width="1dp"
android:color="#f84d4d"/>
虚线和实线的区别就是有没有dashGap.
这样也就简单的实现了实线的编写.