I\'m using Android Studio. I need to change the color of the Radio Button, after changing the Button Tint Color value to the one I need it works on the preview, but whenever
This can be done in two ways (to support pre-Lollipop):
Use AppCompatRadioButton
:
AppCompatRadioButton radioButton;
// now use following methods to set tint colour
radioButton.setSupportButtonTintMode();
radioButton.setSupportButtonTintList();
Apply this as style to your RadioButton
in your XML:
<style name="RadioButton.Login" parent="Widget.AppCompat.CompoundButton.RadioButton">
<item name="android:textColor">@android:color/white</item>
<item name="buttonTint">@android:color/white</item>
</style>
If you want to change the color, but not change colorControlActivated and colorControlNormal for the entire app, you can override your apptheme just for the radio button by creating a new style:
<android.support.v7.widget.AppCompatRadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:theme="@style/RadioButtonTheme"
android:id="@+id/radioButton"/>
<style name="RadioButtonTheme" parent="@style/AppTheme">
<item name="colorControlActivated">@color/colorAccent</item>
<item name="colorControlNormal">@color/colorPrimaryDark</item>
</style>