在棒棒糖上方的 Android 中查看描边不工作
View Stroke not working in Android above lollipop
Have implemented the View to draw the line its working below kitkat version and it's not working in lollipop and Marshmallow devices.
下面是我的代码:
<View
android:id="@+id/vDottedLine"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginLeft="@dimen/sixteen_dp_margin"
android:layout_marginRight="@dimen/sixteen_dp_margin"
android:background="@drawable/dotted"
android:layerType="software" />
XML file for color
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:height="2dp"
android:color="#000"
android:dashGap="3dp"
android:dashWidth="8dp" />
</shape>
并且还尝试添加 android:layerType="software"
和 android:hardwareAccelerated="true"
以及 false。有解决这个问题的提示吗?
试试这个
创建可绘制文件:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="2dp"
android:color="#999999"
android:dashGap="5dp"
android:dashWidth="2dp" />
<solid android:color="@android:color/transparent" />
<size
android:width="2dp"
android:height="2dp" />
</shape>
您的观点:
<View
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/dash"
android:layerType="software"
android:layout_centerInParent="true" />
Have implemented the View to draw the line its working below kitkat version and it's not working in lollipop and Marshmallow devices.
下面是我的代码:
<View
android:id="@+id/vDottedLine"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginLeft="@dimen/sixteen_dp_margin"
android:layout_marginRight="@dimen/sixteen_dp_margin"
android:background="@drawable/dotted"
android:layerType="software" />
XML file for color
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:height="2dp"
android:color="#000"
android:dashGap="3dp"
android:dashWidth="8dp" />
</shape>
并且还尝试添加 android:layerType="software"
和 android:hardwareAccelerated="true"
以及 false。有解决这个问题的提示吗?
试试这个
创建可绘制文件:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="2dp"
android:color="#999999"
android:dashGap="5dp"
android:dashWidth="2dp" />
<solid android:color="@android:color/transparent" />
<size
android:width="2dp"
android:height="2dp" />
</shape>
您的观点:
<View
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/dash"
android:layerType="software"
android:layout_centerInParent="true" />