<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <stroke android:width="1dp" android:color="#D5D5D5" android:dashGap="3dp" android:dashWidth="2dp" /> </shape><View android:id="@+id/product_item_line" android:layout_width="match_parent" android:layout_height="2dp" android:layout_margin="5dp" android:background="@drawable/shape_dotted_line" />
从android3.0开始,安卓关闭了硬件加速功能,所以就不能显示了
所以就是在 AndroidManifest.xml,或者是在activity中把硬件加速的功能关掉就可以了android:hardwareAccelerated="false"
或者是view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
注意:1.view的height要高于 stroke的width预览才显示,但真机运行显示为实线。
2.viewHolder.product_item_line.setLayerType(View.LAYER_TYPE_SOFTWARE , null); 经过设置后,真机运行后显示为虚线了。
shape 画虚线
最新推荐文章于 2022-01-26 15:45:27 发布