RadioButton:
第一种:
在style文件里面:
<style name="MyRadioButton" parent="Theme.AppCompat.Light">
<item name="colorControlNormal">@color/colorPrimary</item>
<item name="colorControlActivated">@color/colorAccent</item>
</style>
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>
第二种:仅适用于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"
/>
values–>colors
<color name="your_color">#e75748</color>
第三种:
图片选择,未测试
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"/>
在style文件里面:
<style name="MyCheckBox" parent="Theme.AppCompat.Light">
<item name="colorControlNormal">@color/grey</item>
<item name="colorControlActivated">@color/mediumturquoise</item>
</style>