G
G
geron2017-04-11 11:37:23
Android
geron, 2017-04-11 11:37:23

How to change color of RadioButton using selector?

Hello!
There are several radio groups in them there is a radio button. When you click on the radio button, the size of the button and its color change. I implemented the change of size and color, but there was a bug. When you click on several radio batans in a row, the next one can only change the size, but not the color.
pictures
step 1
416317f2556e497b9c37066fdcef2e0f.png
step 2
941d43b0d2ae4921a7fcfc19b556a989.png
step 3
922fbf5b18344c3dadac95526cae133d.png
How to enter RB 1.1 only changes size but not color
selector code

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

    <item android:state_pressed="true" >
        <shape android:shape="rectangle" >
            <stroke android:width="1dip" android:color="@color/btn_yellow" />
            <solid android:color="@color/btn_yellow" />
        </shape>
    </item>
    
    <item android:state_checked="true">
        <shape android:shape="rectangle" >
            <stroke android:width="1dip" android:color="@color/btn_yellow" />
            <solid android:color="@color/btn_yellow" />
        </shape>
    </item>

    <item>
        <shape android:shape="rectangle"  >
            <stroke android:width="1dip" android:color="@color/grey" />
            <solid android:color="@color/grey" />
        </shape>
    </item>
</selector>

That is, the radio button changes size after several steps, but does not change color.
Please tell me how to solve this problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question