Reputation: 609
How to create dotted line in blue square using shape tag? I need to create button like below.
Do you have any nice idea?
I used stroke to create dotted line, but no padding outside of the dotted line.
<stroke
android:color="#C7B299"
android:dashWidth="10px"
android:dashGap="10px"
android:width="1dp"/>
Upvotes: 0
Views: 48
Reputation: 325
Here is my suggestion:-
<LinearLayout
android:layout_width="match_parent"
android:background="your background color"
android:padding="5dp"
android:layout_height="60dp">
<TextView
android:text="Hello dashed"
android:gravity="center"
android:textColor="@color/white"
android:background="dotted drawable"
android:layout_width="match_parent"
android:layout_height="match_parent"></TextView>
</LinearLayout>
this is dotted drawable :-
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="3dp"
android:color="@color/white"
android:dashWidth="8dp"
android:dashGap="4dp"/>
</shape>
Upvotes: 1
Reputation: 114
Check out to create a shape and use that as a background or boarder
the shape could be a line and have attributes.
android:dashWidth="x"
android:dashGap="x"
Upvotes: 0
Reputation: 7
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:dashGap="3dp"
android:dashWidth="3dp"
android:color="@color/color_red"
android:width="1dp"/>
<size android:height="1dp"/>
you can try it use above code
Upvotes: 0