Android button background shape -


i want create radio button looks this:

enter image description here

that is, when selected, checkmark shows indicate selected instead of dot. when unselected, there orange background (or other color).

the black background of page background of app.

i know create different drawables different state each button, not extensible if there lot of colors.

i thinking add checkmark image drawable android:button attribute , supply different colors android:background radio buttons. doesn't work because shape of background square. ended having square button.

what best way implement such button? or, how change background shape round/oval instead of square?

this have right now:

<!-- layout.xml --> <radiobutton     android:id="@+id/radio1"     android:layout_width="40dp"     android:layout_height="40dp"     android:background="@color/orange"     android:button="@drawable/radio"/>  <!-- drawable/radio.xml --> <item      android:state_checked="true"      android:drawable="@drawable/checkmark_on_oval"     > </item>     

try may helpful you. put radio_button properties like

    <radiobutton         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:button="@null"         android:checked="true"         android:drawableleft="@drawable/radio_button_selector"         android:drawablepadding="5dp"         android:paddingleft="2dp" /> 

in drawable folder put rb_drawable.xml

<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android">      <item android:drawable="@drawable/radio_button_unchecked" android:state_checkable="true"/> <!-- pressed -->     <item android:drawable="@drawable/radio_button_checked" android:state_checked="true"/> <!-- focused -->     <item android:drawable="@drawable/radio_button_unchecked"/> <!-- default -->  </selector> 

here radio_button_unchecked , radio_button_checked 2 images radio buttons.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -