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 I launch the app on a device the button is the standard green/blue-ish color.
Is this some kind of device API level issue? If so, is it possible to change the color for older devices?
Just use the android:buttonTint="@color/colorPrimary" attribute on the <RadioButton> tag. Show activity on this post. to the colour you want.
Show activity on this post. When I open a new android studio project, the default color for button is purple.
↳ android.widget.RadioGroup. This class is used to create a multiple-exclusion scope for a set of radio buttons. Checking one radio button that belongs to a radio group unchecks any previously checked radio button within the same group. Intially, all of the radio buttons are unchecked.
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>
RadioButton raPrivate = (RadioButton) layout.findViewById(R.id.radioPrivate);
int textColor = Color.parseColor(#000000);
raPrivate.setButtonTintList(ColorStateList.valueOf(textColor));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With