Is it possible to change the color of the radio button
in the Android spinner widget. By default it displays the green color for the radio button.
I need to change it to some other color, is it possible, and how?
Android Spinner is a view similar to the dropdown list which is used to select one option from the list of options. It provides an easy way to select one item from the list of items and it shows a dropdown list of all values when we click on it.
Try removing the xml attribute android:clickable="true" from the Spinner widget. It could be that the entire spinner is registering the click event rather than the individual spinner items.
Android Spinner class is the subclass of AsbSpinner class.
I know this is an old question now, but here goes...
You will need to create a custom Theme and apply it to the Activity with your spinner.
First, you need to create images for the checked/unchecked states of the 'new' radio, you could just pull the given images btn_radio_on.png
and btn_radio_off.png
from the sdk's res/drawable-*
folder(s). Edit them to look how you want (such as changing color or whatever) and save off to your project.
Next, create a new xml file in your res/values
folder, and add the following:
<resources>
<style name="CustomSpinnerRadioTheme" parent="@android:style/Theme">
<item name="android:spinnerDropDownItemStyle">@style/EditedRadio</item>
</style>
<style name="EditedRadio" parent="@android:style/Widget.DropDownItem.Spinner">
<item name="android:checkMark">@drawable/edited_radio</item>
</style>
</resources>
Then, create another xml file in res/drawable
named edited_radio.xml
, and it should contain the following:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false" android:drawable="@drawable/btn_radio_off" />
<item android:state_checked="true" android:drawable="@drawable/btn_radio_on" />
</selector>
just be sure to reference your edited images for the checked states. Then you just have to apply the CustomSpinnerRadioTheme
to your Activity and run!
A good resource I found is Applying Styles and Themes especially the additional reference on Android Styles (styles.xml) and Android Themes (themes.xml)
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