2016-04-11 10 views
-1

Haben Sie die Ansicht implementiert, um die Linie zu zeichnen, die unterhalb der kitkat-Version arbeitet und nicht in Lollypop und Marshmallow-Geräten funktioniert.View Stroke funktioniert nicht in Andirds über Lollipop

Unten ist mein Code:

<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-Datei für die Farb

<?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> 

Und auch versucht, das Hinzufügen android:layerType="software" und android:hardwareAccelerated="true" und falsch als auch. Irgendein Hinweis, um dieses Problem zu überwinden?

Antwort

1

Versuchen Sie, diese

ziehbar-Datei erstellen:

<?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> 

Ihre Ansicht:

<View 
    android:layout_width="100dp" 
    android:layout_height="100dp" 
    android:background="@drawable/dash" 
    android:layerType="software" 
    android:layout_centerInParent="true" /> 
+0

Dank Rajesh. Perfekt funktioniert – John