java - How can I develop this kind of Button -
this button has outer white rong , inner grey background.
inner background contains image (tickmark) , text (apply).
i able make shape (below).
i using shape in drawable (button.xml):
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="oval"> <size android:height="85dp" android:width="90dp"/> <solid android:color="@color/grey"/> <stroke android:color="@color/white" android:width="4dp"></stroke> </shape> </item> <item android:drawable="@drawable/checkmark_filled" android:bottom="20dp" android:left="20dp" android:right="20dp" android:top="20dp"/> </layer-list>
and using imageview use shape
<imageview android:id="@+id/button_apply" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/button"/>
but not able make text in shape.
missing or there way possible?
what this:
1 - separate layerlist 2 distinct drawables
circle.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" > <size android:height="85dp" android:width="90dp" /> <solid android:color="@color/grey" /> <stroke android:color="@color/white" android:width="4dp" /> </shape>
i assume have bitmap: drawable/checkmark_filled
2 - use textview, instead of imageview:
<textview android:id="@+id/button_apply" android:layout_width="wrap_content" android:layout_height="wrap_content" android:backgound="@drawable/button" android:drawabletop="drawable/checkmark_filled" android:text="apply" android:clickable="true" />
adjust gravity , paddings needed.
set other properties needed.
note can (and should) use string resource, instead of hard-coded text.
brief explanation:
- i'm using oval shape textview brackground.
- i'm using checkmark bitmap compound drawable.
- i'm using textview's text write something.
- i set textview
clickable
, can use if button.
Comments
Post a Comment