gpt4 book ai didi

android - RadioButton 设置圆的填充颜色

转载 作者:行者123 更新时间:2023-12-04 08:33:52 26 4
gpt4 key购买 nike

在我的布局中,我有一个 AppCompatRadioButton。使用 app:buttonTint 我将按钮设置为白色。如果我检查了 AppCompatRadioButton,圆圈的填充颜色也是白色。当选中按钮时,如何仅更改圆圈的填充颜色?示例:单击时,圆圈变为白色,并且圆圈的填充颜色将更改为红色。

最佳答案

第 1 步如果您只想更改颜色,可以使用主题。

styles.xml

<style name="MyCheckBox" parent="Theme.AppCompat.NoActionBar">
<item name="colorControlNormal">#d1d1d1</item> <!-- normal border color change as you wish -->
<item name="colorControlActivated">#359e1d</item> <!-- activated color change as you wish -->
<item name="android:textColor">#FFFF3F3C</item> <!-- checkbox text color -->
</style>

在您的布局中

  <android.support.v7.widget.AppCompatRadioButton
android:id="@+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Text"
android:theme="@style/MyCheckBox"
android:textSize="16dp" />

第2步如果您想更改rabio按钮的图标

在您的布局中

   <android.support.v7.widget.AppCompatRadioButton
android:id="@+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Text"
android:button="@drawable/cb_selector"
android:textSize="16dp" />

您的绘图

 <?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/icon_tick" />
<item android:state_checked="false" android:drawable="@drawable/icon_un_tick" />
</selector>

关于android - RadioButton 设置圆的填充颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51760752/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com