Alex Terreaux Alex Terreaux - 1 year ago 94
Android Question

Android 5.0 makes unselected checkboxes invisible when background is white

I have an android app that has been working fine pre-Android 5.0. With the update, I noticed that checkboxes and radiobuttons placed on white backgrounds are not visible if they are not selected. For example, this is what a checkbox looks selected and unselected in jellybean:

enter image description here enter image description here

As you can see, there is a light gray square when the checkbox is not selected. However, after updating to lollipop, this is what it looks like:

enter image description hereenter image description here

So, as you can see, there is no gray square or anything that suggests there is a checkbox here. The same problem happens with radiobuttons. I really don't want to go trough the pain of creating new drawables just for this simple ting. I have seen that checkboxes within the accessibility menu of android 5 have a nice square, but haven't figured out how to make mine look the same:

enter image description here

I tried creating a new android project and just adding some checkboxes and radio buttons with a white background, but they are still invisible when unchecked. I'm using xamarin studio and c#, if that makes any difference. Anyway, I'll understand any java code you post.

This is what my checkbox code looks like:


Answer Source

Make sure you are using a Material theme for Android 5.0 devices - this will ensure you're styling remains consistent with other components. Look for an android:theme element in your AndroidManifest.xml file (either on your application or on an individual activity), then look up what style is set there and check the parent attribute for the style.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download