Create a Horizontal dotted line in android layout -
in layout trying draw dotted line.for drawing horizontal line defining view in layout file.
<view android:layout_width="fill_parent" android:layout_height="1dip" android:background="@drawable/customdots" />
and customdots.xml
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:left="10dp" android:right="10dp" android:width="4dp" android:drawable="@drawable/dotted" /> </layer-list>
dotted.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line" > <size android:height="4dp" android:width="1024dp"/> <stroke android:width="4dp" android:dashwidth="4dp" android:color="@android:color/black" android:dashgap="5dp"/> </shape>
but don't line using code. please me out.
when use customdots.xml in listview divider as
android:divider="@drawable/customdots"
it shows dotted line
i pulling hair on issue until figured out there bug in latest versions of android when rendering lines this.
this bug can circumvented adding android:layertype="software" view using dotted line background.
example:
dotted.xml:
<?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:height="2px" android:color="#ffffff" /> </shape>
layout.xml:
<view android:id="@+id/vdottedline" android:background="@drawable/dotted" android:layout_width="match_parent" android:layout_height="2px" android:layertype="software" />
Comments
Post a Comment