能夠說這是一個Bug, 聽說在4.0以上機器會出現,我測試是Android 4.4.2html
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line" > <stroke android:dashGap="3dp" android:dashWidth="8dp" android:width="1dp" android:color="#999999" /> <size android:height="1dp" /> </shape>
layout中引用:android
Xml代碼 ide
<View android:layout_width="match_parent" android:layout_height="3dp" android:layout_marginBottom="5dp" android:layout_marginTop="5dp" android:background="@drawable/left_menu_dash_line" />
在4.4.2上顯示實線。測試
解決:ui
Xml代碼 .net
<View android:layerType="software" android:layout_width="match_parent" android:layout_height="3dp" android:layout_marginBottom="5dp" android:layout_marginTop="5dp" android:background="@drawable/left_menu_dash_line" />
重點:3d
Xml代碼 code
android:layerType="software"
也能夠:xml
Java代碼 htm
<activity android:name=".TestActivity" android:label="Test" android:hardwareAccelerated="false">
重點關閉硬件加速:
Java代碼
android:hardwareAccelerated="false"
divider_under_pic.setLayerType(View.LAYER_TYPE_SOFTWARE,null);
代碼中使用setLayerType設置。
參考:
http://developer.android.com/guide/topics/graphics/hardware-accel.html