Dotted line separator with custom thickness

柔情痞子 提交于 2019-12-03 15:46:10
Raghunandan

You can use stroke width,

android:width="3dp"

snapshot

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" />

you can define a line like

<?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="#E90C0C" />

</shape>

and use it in your view as

<View
    android:id="@+id/vDottedLine"
    android:background="@drawable/dotted"
    android:layout_width="match_parent"
    android:layout_height="2px"
    android:layerType="software" />
NagarjunaReddy

use like this it is use full And THIS DOTTED LINE IN ANDROID

EDIT : Here is Answer

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

   <solid android:color="#fdfdfd" >
   </solid>

 <stroke
  android:dashGap="5px"
  android:dashWidth="5px"
  android:width="2dp"
  android:color="@color/scoreColor" >
</stroke>

</shape>

in xml file use this

NOTE : Note: With out this line in Higher versions not working android:layerType="software"

 <View
    android:layout_width="match_parent"
    android:layout_height="5dip"
    android:background="@drawable/dash_line"
    android:layerType="software"
    android:orientation="vertical" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!