如何在android中更改单选按钮的边框颜色?

时间:2013-04-25 11:10:50

标签: android android-ui

如何更改android中单选按钮的边框颜色?

我想更改android单选按钮的圆圈颜色。

提前致谢。非常感谢任何帮助。

我尝试了不同的解决方案和关注,如果有任何属性是其他可绘制图像

4 个答案:

答案 0 :(得分:20)

是的,这是您正在寻找的属性:buttonTint,但仅适用于21级或以上的api

<RadioButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/radio"
    android:checked="true"
    android:buttonTint="@color/your_color"/>

在你的values / colors.xml中,你的颜色在这种情况下是红色的:

<color name="your_color">#e75748</color>

结果:

Colored Android Radio Button

答案 1 :(得分:17)

自定义(更改颜色)视图的最简单方法。

转到:http://android-holo-colors.com/

  • 选择“单选按钮”所需的颜色
  • 下载输出资源(Download.Zip)
  • 提取zip内容
  • 将提取的zip文件复制到项目的drawable,样式和值
  • 将应用主题的父级更改为您下载的
  • 你有你想要的东西

答案 2 :(得分:3)

尝试使用AppCompatRadioButton

  decimal value = 0.00M;
        value = Convert.ToDecimal(12345.12345);
        Console.WriteLine(".ToString(\"C\") Formates With Currency $ Sign");
        Console.WriteLine(value.ToString("C"));
        //OutPut : $12345.12
        Console.WriteLine(value.ToString("C1"));
        //OutPut : $12345.1
        Console.WriteLine(value.ToString("C2"));
        //OutPut : $12345.12
        Console.WriteLine(value.ToString("C3"));
        //OutPut : $12345.123
        Console.WriteLine(value.ToString("C4"));
        //OutPut : $12345.1235
        Console.WriteLine(value.ToString("C5"));
        //OutPut : $12345.12345
        Console.WriteLine(value.ToString("C6"));
        //OutPut : $12345.123450
        Console.WriteLine();
        Console.WriteLine(".ToString(\"F\") Formates With out Currency Sign");
        Console.WriteLine(value.ToString("F"));
        //OutPut : 12345.12
        Console.WriteLine(value.ToString("F1"));
        //OutPut : 12345.1
        Console.WriteLine(value.ToString("F2"));
        //OutPut : 12345.12
        Console.WriteLine(value.ToString("F3"));
        //OutPut : 12345.123
        Console.WriteLine(value.ToString("F4"));
        //OutPut : 12345.1235
        Console.WriteLine(value.ToString("F5"));
        //OutPut : 12345.12345
        Console.WriteLine(value.ToString("F6"));
        //OutPut : 12345.123450

        Console.WriteLine();
        Console.WriteLine(".ToString(\"N\") Formates With out Currency Sign");
        Console.WriteLine(value.ToString("N"));
        //OutPut : 12,345.12
        Console.WriteLine(value.ToString("N1"));
        //OutPut : 12,345.1
        Console.WriteLine(value.ToString("N2"));
        //OutPut : 12,345.12
        Console.WriteLine(value.ToString("N3"));
        //OutPut : 12,345.123
        Console.WriteLine(value.ToString("N4"));
        //OutPut : 12,345.1235
        Console.WriteLine(value.ToString("N5"));
        //OutPut : 12,345.12345
        Console.WriteLine(value.ToString("N6"));
        //OutPut : 12,345.123450

        Console.WriteLine();
        Console.WriteLine(".ToString(\"P\") Formates With Percentage (i.e multiply by 100)");
        Console.WriteLine(value.ToString("P"));
        //OutPut : 1,2345,12.35%
        Console.WriteLine(value.ToString("P1"));
        //OutPut : 1,2345,12.3%
        Console.WriteLine(value.ToString("P2"));
        //OutPut : 12345,12.35%
        Console.WriteLine(value.ToString("P3"));
        //OutPut : 12345,12.345%
        Console.WriteLine(value.ToString("P4"));
        //OutPut : 12345,12.3450%
        Console.WriteLine(value.ToString("P5"));
        //OutPut : 12345,12.34500%
        Console.WriteLine(value.ToString("P6"));
        //OutPut : 12345,12.345000%


        Console.Read();

有关详细信息,请查看以下答案:Android: Change the color of RadioButtons and checkboxes programmatically

答案 3 :(得分:2)

我认为您正在尝试自定义内置单选按钮。试试这个链接。这是你的解决方案。全场决赛。 Click here