5

I am putting a CheckBox against a white background. It looks fine on pre-Honeycomb devices but on Honeycomb, it seems that the graphic has partial transparency and is white, so when the checkbox is unticked, you cannot see it.

I tried using the Theme.Holo.Light style as follows:

<CheckBox android:text="" style="@android:style/Theme.Holo.Light"
android:layout_marginLeft="5dip" android:id="@+id/checkBoxWifiOnly" 
android:layout_width="wrap_content" android:layout_height="wrap_content" />

This appears to have no effect. Am I typing the syntax wrongly?

albnok
  • 521
  • 2
  • 14
  • If you eyeing for the custom checkbox then follow this [link][1] [1]: http://stackoverflow.com/questions/3569412/customize-check-box-preference – mayank_droid Sep 19 '11 at 06:09
  • Thanks, but I am not looking to make it a custom checkbox, just to change it to the standard checkbox-on-white style - right now it's a checkbox-on-black so you can't see the box when unticked. – albnok Sep 19 '11 at 08:20

1 Answers1

2

You are applying the theme in a wrong way. Either apply @android:style/Theme.Holo.Light to the whole app/activity in the AndroidManifest.xml, or use @android:style/Widget.Holo.Light.CompoundButton.CheckBox as the style of your CheckBox. Also note that the "Holo" theme is available only on Honeycomb and higher.

I think that you'll have to apply the theme to the whole app, if you want the checkbox to have a different background. The thing is, that Widget.Holo.Light.CompoundButton.CheckBox and Widget.Holo.CompoundButton.CheckBox are the same and both extend the Widget.CompoundButton.CheckBox style, which has the "button" variable set by the theme attribute listChoiceIndicatorMultiple. This attribute's value is, in fact, different for light and dark theme.

I'd suggest you to create your own theme in values/themes.xml file, like this:

<style name="Theme.MyAwesomeApp" parent="@android:style/Theme.Light">
...
</style>

and in values-v11/themes.xml, like this:

<style name="Theme.MyAwesomeApp" parent="@android:style/Theme.Holo.Light">
...
</style>

and then set it in your AndroidManifest.xml, like this:

<application android:theme="@style/Theme.MyAwesomeApp" ... >
...
</application>

Maybe you should also read how the themes and styles work: https://developer.android.com/guide/topics/ui/themes.html

cermak.cz
  • 551
  • 2
  • 8