shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="@dimen/dimen_1_dip"
android:color="#000000"
android:dashWidth="@dimen/dimen_10_dip"
android:dashGap="@dimen/dimen_10_dip" />
</shape>
定义shape文件如下
但是使用之后在真机上没有虚线效果
根据网上大神们的解释是使用hardwareAccelerate引起的渲染错误...解决方法如下:
1. 把这个Activity的硬件加速关了... manifest里 android:hardwareAccelerated="false"
2. 或者从View层级上把硬件加速关掉 view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
2. 或者从View层级上把硬件加速关掉 view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
亲测有效,特此记录。