Sie*_*imo 23
刚刚来展示一些真正帮助我的东西:
每个人都在谈论如何使用色调以及如何使用colorAccent,但是,这不适用于API小于21的手机.
所以,真正的解决方案或至少是帮助我的是使用android.support.v7.widget.AppCompatRadioButton而不是RadioButton
在您的布局上使用此选项,您可以使用:
app:buttonTint="@color/yourColor"
没有得到关于视图的compat的警告或问题.
而且,你不要忘记添加:
xmlns:app="http://schemas.android.com/apk/res-auto"
到您的布局父级或您的小部件.
编辑:
@aselims提一个意见,即有没有buttonTint在app命名空间.
所以...这是我目前的解决方案风格:
<style name="MRadioButton.Purple" parent="Widget.AppCompat.CompoundButton.RadioButton">
<item name="colorAccent">@color/youColor</item>
<item name="colorControlHighlight">@color/yourColor</item>
<item name="android:colorPressedHighlight">@color/yourColor</item>
<item name="colorPrimaryDark">@color/yourColor</item>
<item name="colorPrimary">@color/yourColor</item>
<item name="colorControlActivated">@color/yourColor</item>
</style>
Run Code Online (Sandbox Code Playgroud)
Jor*_*any 17
最快的方法是设置buttonTint所需的颜色:
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radio"
android:checked="true"
android:buttonTint="@color/your_color"/>
Run Code Online (Sandbox Code Playgroud)
在values/colors.xml这种情况下你的颜色是红色的:
<color name="your_color">#e75748</color>
Run Code Online (Sandbox Code Playgroud)
结果:

正如@smashing指出的那样,这只适用于API级别> = 21
要以编程方式更改RadioButton按钮颜色,并在api级别<21上工作,应使用AppCompatRadioButton而不是RadioButton:
(否则会警告setbuttontintlist requrie api level 21)
import android.support.v7.widget.AppCompatRadioButton;
AppCompatRadioButton radioButton = new AppCompatRadioButton(getActivity());
radioButton.setSupportButtonTintList(
ContextCompat.getColorStateList(getActivity(),
R.color.single_choice_state_list));
Run Code Online (Sandbox Code Playgroud)
single_choice_state_list.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@color/single_choice_checked"></item>
<item android:state_checked="false" android:color="@color/single_choice_unchecked"></item>
</selector>
Run Code Online (Sandbox Code Playgroud)