0

I try to create custom radio button but the result is not good, with this code: custom_radio.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/radio_on" android:state_checked="true"/>
    <item android:drawable="@drawable/radio_on" android:state_pressed="true"/>
    <item android:drawable="@drawable/radio_off"/>

</selector>

and main.xml

<RadioGroup
                    android:id="@+id/radioSex"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="25dp"
                    android:orientation="vertical" >

                    <RadioButton
                        android:id="@+id/male"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:checked="true"
                        android:text="@string/male"
                        android:background="@xml/custom_radio"
                        android:textColor="@color/white" />

                    <RadioButton
                        android:id="@+id/female"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/female"
                        android:background="@xml/custom_radio"
                        android:textColor="@color/white" />
                </RadioGroup>

the result is this: enter image description here

How to solve this ?

HK.avdalyan
  • 724
  • 1
  • 6
  • 21

1 Answers1

1

add

 android:button="@null"

to your RadioButton. Also drawable like xml should be placed inside the drawable folder

Eenvincible
  • 5,641
  • 2
  • 27
  • 46
Blackbelt
  • 156,034
  • 29
  • 297
  • 305