简体   繁体   English

单选按钮上的圆形和圆点颜色

[英]RadioButton circle and dot color on selected

I'm trying to change the ugly pink color that radioButton has when on pressed. 我正在尝试更改单选按钮按下时的难看的粉红色。 I've been looking for it but seems like no one has the proper answer on how to do it. 我一直在寻找它,但似乎没有人对如何做有正确的答案。 Do you recommend me styles or do it programmatically? 您向我推荐样式还是通过编程进行?

This is my xml layout of the radioButtons: 这是单选按钮的xml布局:

<RadioGroup
    android:layout_width="200dp"
    android:layout_height="250dp"
    android:id="@+id/radioGroup"
    android:orientation="vertical"
    android:layout_above="@+id/btSig"
    android:layout_centerHorizontal="true">

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New RadioButton"
        android:id="@+id/primero"
        android:layout_marginTop="10dp"
        android:onClick="pulsado"
        android:textSize="17dp"
        />

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New RadioButton"
        android:id="@+id/segundo"
        android:layout_marginTop="10dp"
        android:onClick="pulsado"
        android:textSize="17dp"
        />

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New RadioButton"
        android:id="@+id/tercero"
        android:layout_marginTop="10dp"
        android:onClick="pulsado"
        android:textSize="17dp"
        />
</RadioGroup>

我想在按下时改变粉红色的颜色。 Thank you for the help! 感谢您的帮助!

You can change it with like that android:buttonTint="#a14545" 您可以使用android:buttonTint="#a14545"

Code Example 代码示例

<RadioButton
        android:id="@+id/rb_mini_layout_selection_word_types_all"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:checked="true"
        android:text="all"
        android:buttonTint="#a14545" />         

The simplest way to change the default RadioButton color app-wide is to change it in your res folder. 应用程序范围内更改默认RadioButton颜色的最简单方法是在res文件夹中进行更改。
In your project, go to app > res > values > colors.xml . 在您的项目中,转到app > res > values > colors.xml This XML file contains the colors for your app in HEX values. 此XML文件以十六进制值包含您的应用程序的颜色。
You will most likely see three XML values under <resources> . 您很可能会在<resources>下看到三个XML值。 Remember, the colorAccent value changes the RadioButton select color. 请记住, colorAccent值会更改RadioButton选择颜色。 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM