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).

http://imgur.com/a/nfxkr

i able make shape (below).

http://imgur.com/k0csym3

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

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -