Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dotted line separator with custom thickness

I have a dotted line separator

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">

    <!-- 
#17b851 #C7B299
     -->
    <stroke
       android:color="#9e9c85"
       android:dashWidth="10px"
       android:dashGap="10px" 
       />
</shape>

Right now its barely visible. How can I make it thick . I tried giving android:height="2px" & android:dashHeight="5px" but it didnt work.

like image 905
Vihaan Verma Avatar asked Jan 28 '14 06:01

Vihaan Verma


2 Answers

Stroke WIDTH must be smaller than the size HEIGHT.

(Stroke width is the width of the line. Size height is the height of the drawable. When drawn, the line is centered in the drawable. If size height <=stroke width, the line won't show up.)

dottedline.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line" >

    <stroke
        android:dashGap="3dp"
        android:dashWidth="3dp"
        android:width="2dp"
        android:color="@android:color/black" />

    <size android:height="3dp" />
</shape>

the layout xml:

<ImageView
        android:layerType="software"
        android:contentDescription="underline"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/dottedline" />
like image 79
furnaceX Avatar answered Oct 28 '22 22:10

furnaceX


You can use stroke width,

android:width="3dp"

snapshot

enter image description here

like image 27
Raghunandan Avatar answered Oct 28 '22 20:10

Raghunandan