@color/colorPrimary @color/colorAccent_radiobutton边框颜色">
当前位置:   article > 正文

RadioButton改变圆圈颜色、CheckBox改变框的颜色_radiobutton边框颜色

radiobutton边框颜色

RadioButton
第一种:
在style文件里面:

<style name="MyRadioButton" parent="Theme.AppCompat.Light">
        <item name="colorControlNormal">@color/colorPrimary</item>
        <item name="colorControlActivated">@color/colorAccent</item>
    </style>
  • 1
  • 2
  • 3
  • 4

xml布局:记住一定是theme,不能用style,style根本改变不了颜色

<RadioGroup
        android:id="@+id/rg_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <RadioButton
            android:id="@+id/rb_one"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:text="女"
            android:theme="@style/MyRadioButton"
            />

        <RadioButton
            android:id="@+id/rb_two"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:text="男"
            android:theme="@style/MyRadioButton" />

        <RadioButton
            android:id="@+id/rb_three"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:text="男"
            android:theme="@style/MyRadioButton" />

        <RadioButton
            android:id="@+id/rb_four"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:text="男"
            android:theme="@style/MyRadioButton" />
    </RadioGroup>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35

第二种:仅适用于api level 21或更高版本

<RadioButton
            android:id="@+id/rb_one"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:text="女"
            android:buttonTint="@color/your_color"
            />
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

values–>colors

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

第三种:
图片选择,未测试

CheckBox:

 <CheckBox
            android:id="@+id/cb_three"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:text="男"
            android:theme="@style/MyCheckBox"
            android:textColor="@color/view_title_text"/>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

在style文件里面:

<style name="MyCheckBox" parent="Theme.AppCompat.Light">
        <item name="colorControlNormal">@color/grey</item>
        <item name="colorControlActivated">@color/mediumturquoise</item>
    </style>
  • 1
  • 2
  • 3
  • 4
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/733666
推荐阅读
相关标签
  

闽ICP备14008679号