【问题标题】:How to change the circle color of the radio button programmatically?如何以编程方式更改单选按钮的圆圈颜色?
【发布时间】:2020-05-22 14:16:52
【问题描述】:

我有一个将以编程方式填充的 RadioGroup(我正在使用 kotlin),我想更改单选按钮的圆形颜色(尽量避免强调色解决方案)。

** XML

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

** 科特林

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)
}

【问题讨论】:

标签: android android-layout kotlin android-radiobutton


【解决方案1】:

你可以使用

android:buttonTint="your color"

对于 API

app:buttonTint="your color" 

改变 RadioButton 中圆圈的颜色

【讨论】:

  • 编辑了我的答案,现在检查
  • 我说的是“以编程方式”
猜你喜欢
  • 1970-01-01
  • 2019-05-20
  • 2013-04-25
  • 2020-08-20
  • 2020-10-10
  • 2010-12-21
  • 2022-12-12
  • 1970-01-01
  • 2016-11-06
相关资源
最近更新 更多