How do I just change the text color of checkbox views in Android Studio's styles.xml?
I want to create a theme where all checkbox items are a color different from the default black like:
Except I want the box itself to be the same color as the text.
Should I be using the following in my theme?
<item name="android:checkboxStyle">@style/App_CheckboxStyle</item>
The solution for me was to use textColor property:
There is no attribute has impact on Checkbox text color at theme level.
All you can do to change text color is to define a style as shown below and apply it to checkbox using style attribute.
http://www.zoftino.com/android-ui-control-checkbox
You can change color by using drawable like this
in you layout just use button property
I know that this question is asked long time ago but I want to add my solution. It works with all SDK versions.
You are right that in order to change CheckBox style in the whole project, you have to add the line to your theme:
And the style itself, where you set your custom text and checkbox color:
Note:
android:
prefix indicates that a property is linked to SDK attributes. If you remove it, the property links to support library. That's why system treatsbuttonTint
andandroid:buttonTint
as different parameters. If your minimum SDK is 21, you don't need to use support library and you can simply useandroid:buttonTint
.You can use
android:textColorPrimaryDisableOnly
for changeCheckBox
/RadioButton
textColor
andcolorAccent
for change the drawableYou can change the color of the
checkbox
, using this:You can change the color of the
textView
in thecheckbox
, using this:For example:
Else, create 3
xml
files for customized colors as mentioned in this answer (look where it says Second Method).