0

Image(Edited):

enter image description here

I have two drawables for radio button.One for normal state and other for checked state.When I set it to button attribute of radio button it was not visible.Please tell me what I am doing wrong here.

radio_pressed:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
<shape android:shape="ring"
    android:useLevel="false"
    android:thickness="1dp"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <solid
        android:color="#ffffff">
    </solid>
    <size
        android:height="10dp"
        android:width="10dp">
    </size>
</shape>
    </item>
    <item
        android:top="3dp"
        android:bottom="3dp"
        android:right="3dp"
        android:left="3dp">
        <shape android:shape="oval"
          android:useLevel="false"
            >
            <solid
                android:color="#ffffff">
            </solid>
        </shape>
    </item>
</layer-list> 

radio_normal:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="ring"
    android:useLevel="false"
    android:thickness="10dp">
    <solid
        android:color="#2196f3">
    </solid>
</shape>

radio_bg:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:state_checked="true"
    android:drawable="@drawable/radio_pressed"
    >
</item>
    <item
        android:state_checked="false"
        android:drawable="@drawable/radio_normal"
        >
    </item>
</selector>

activity_main.xml:

<RadioButton
        android:id="@+id/radio"
        android:layout_centerInParent="true"
        android:layout_width="40dp"
        android:button="@drawable/radio_bg"
        android:layout_marginTop="100dp"
        android:layout_height="40dp"
        />
jobin
  • 1,489
  • 5
  • 27
  • 52

0 Answers0