0

I have some RadioButtons inside a RadioGroup and I am using custon icons to replace the typical radio "dot".

I have my normal state (checked=false) and checked state (checked=true) sorted.

However, when tapping/pressing the RadioButton, there is a grey-ish highlight colour in the background, that is round in shape (to match the original radio dot).

How can I customise this highlight colour? I tried using "android:state_pressed" but that didn't seem to do anything? (Well, I tried adding a shape, as mentioned here: https://stackoverflow.com/a/14602078/601869)

Ideally, I'd like the shape to match that of the icon (well, most probably be a bit bigger) and change the colour.

Selector XML:

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

RadioButton XML:

<RadioButton
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/radioButton01"
        android:button="@drawable/rounded_radio_select" />
Community
  • 1
  • 1
Mr Pablo
  • 4,109
  • 8
  • 51
  • 104

1 Answers1

0

try changing

android:button="@drawable/rounded_radio_select" />

to

android:background="@drawable/rounded_radio_select" android:button="@android:color/transparent"/>

Maybe this is the same issue Adding custom radio buttons in android

Community
  • 1
  • 1
matty357
  • 637
  • 4
  • 16