1

I have a RadioGroup that will be populated programmatically (I'm using kotlin) and I want to change the circle color of the radio button (try to avoid the accent color solution).

** XML

<RadioGroup
    android:id="@+id/radio_group"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="8dp" />

** Kotlin

for (entry in entries) {

    val rb = RadioButton(applicationContext)

    rb .text = entry
    rb .id = entries.indexOf(entry) + 100
    rb .setTextColor(Color.BLACK)
    rb .isChecked = (entries.indexOf(entry) == 0)

    rbg.addView(rb)
}
Rahul Gaur
  • 1,661
  • 1
  • 13
  • 29
Mohamed Jihed Jaouadi
  • 1,427
  • 4
  • 25
  • 44
  • https://stackoverflow.com/questions/53852253/how-to-change-checked-color-of-radio-button-programmatically or https://stackoverflow.com/questions/17120199/change-circle-color-of-radio-button or https://stackoverflow.com/questions/38212120/how-to-programatically-set-the-colour-of-a-radiobutton-android-circle don't thank me ;-) – Kirguduck Feb 06 '20 at 14:23
  • IT works fine for api > 21 but I consider api 16 – Mohamed Jihed Jaouadi Feb 07 '20 at 08:35

1 Answers1

0

You can use

android:buttonTint="your color"

For API<21

app:buttonTint="your color" 

to change the color of circle in RadioButton