-1

I want to change the actual circle of the RadioButton.

I have looked all over StackOverflow and nothing seems to work.

I am using API 17 and cannot use a ColorStateList. Custom drawables seem to mess us the look and feel of things.

I want the same effect as changing the button hint but I need to do it programmatically.

I'm sure I must please missing something very simple!

Sufian
  • 6,405
  • 16
  • 66
  • 120
SuperBale
  • 341
  • 2
  • 8
  • 20
  • Possible duplicate of [Can't change Radio Button color on Android](http://stackoverflow.com/questions/28307512/cant-change-radio-button-color-on-android) – Sufian Nov 30 '16 at 15:46

1 Answers1

0

Changing color of RadioButton circle can be done by using your own custom images. Lets say you have two circular images for checked and unchecked viz. checkedradiobutton and uncheckedradiobutton. Now Make a xml(custom_radio_button) drawable as below:

<?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/checkedradiobutton" />
<item android:state_checked="false" android:drawable="@drawable/unchekedradiobutton" />

I believe your are creating your Radio button using

  RadioButton rb = new RadionButton(context);
  radioButton.setLayoutParams(new 
  ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 
  ViewGroup.LayoutParams.WRAP_CONTENT));
  radioButton.setTextColor(ContextCompat.
  getColor(context,R.color.royal_blue));

 radioButton.setButtonDrawable(R.drawable.custom_radio_button);//this will change the default circles
Jiten Basnet
  • 1,623
  • 15
  • 31