I am developing an quiz based app. There will be 1 question and 4 option(radio buttons). If user select any wrong answer then I want to turn that radio button color to Red. How to do this?
You can use the CSS accent-color property to change the colour. It works with Chrome/Edge 93+, Firefox 92+, and Safari 15.4+ (Browser support info from caniuse.)
An easy way to change the style of a disabled radio button is a simple absolute positioned overlay with the :after attribute. You can adjust the background color and borders as you see fit. Show activity on this post. Try adding the border colour as i believe thats the initial edge styling.
Go to Edit Form → Settings → Style → Global, and at the Theme colors options you can choose the theme colors.
Just came to show something that really help me with this:
Everyone talks about how to use the tint and how to use the colorAccent, but, this wont work on phones with API less than 21.
So, the real fix on this or at least what helped me was to use android.support.v7.widget.AppCompatRadioButton
instead of RadioButton
With this on your layout, you can use:
app:buttonTint="@color/yourColor"
without getting warnings or problems about the compat of the view.
And, don't you forget about adding:
xmlns:app="http://schemas.android.com/apk/res-auto"
to your layout parent or to your widget.
Edit:
@aselims mention on a comment that there's not buttonTint
in the app
namespace.
So... here's my current style for this solution:
<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>
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