Change Circle color of radio button

Amandeep Singh picture Amandeep Singh · Jun 15, 2013 · Viewed 212.1k times · Source

I want to change the color of the circle of RadioButton in one of my project, I could not understand which property to set. The background color I am having is black so it gets invisible. I want to set the color of the circle to white.

Answer

Jorge Arimany picture Jorge Arimany · Apr 10, 2015

More simple, just set the buttonTint color: (only works on api level 21 or above)

<RadioButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/radio"
    android:checked="true"
    android:buttonTint="@color/your_color"/>

in your values/colors.xml put your color in this case a reddish one:

<color name="your_color">#e75748</color>

Result:

Colored Android Radio Button

If you want to do it by code (also api 21 and above):

if(Build.VERSION.SDK_INT>=21)
{

    ColorStateList colorStateList = new ColorStateList(
            new int[][]{

                    new int[]{-android.R.attr.state_enabled}, //disabled
                    new int[]{android.R.attr.state_enabled} //enabled
            },
            new int[] {

                    Color.BLACK //disabled
                    ,Color.BLUE //enabled

            }
        );                       


    radio.setButtonTintList(colorStateList);//set the color tint list
    radio.invalidate(); //could not be necessary
}