Development issue/problem:

I’m new to android and I’m trying to define a style for all the checkboxes of my application. The style of my application is set to Theme.Holo, which is dark, and I want the checkboxes in my vision list to appear in Theme.Holo.Light style. I’m not trying to create an individual style. The next code doesn’t seem to work, nothing’s happening. I have to do this because my list view has a light paper structure and the check box and the text in the box are white, which I would like to be dark.

You can also define styles for individual widgets if you want to define a style for an application ?

How can I solve this problem?

Solution 1:

Pay attention: Are you using the Android Support Library v22.1.0 and aiming for API level 11 or higher? Scroll down to the latest update.

The style of my app is set to Theme.Holo, which is dark, and I want the checkboxes in my vision list to be in Theme.Holo.Light style.
I’m not trying to create an individual style. The following code doesn’t seem to work
, nothing happens at all.

At first glance, it may not be clear why the system behaves this way, but if you study the mechanics, you can easily distract it. I’ll take you one step at a time.

First, let’s see what defines the Widget.Holo.Light.CompoundButton.CheckBox style. For the sake of clarity I have also included a definition of regular (not light) style.

As you can see both declarations are empty, wrap the Widget.CompoundButton.CheckBox with a different name. So let’s take a look at this style of parenting.

This style applies to both the background and the button display. btn_check_label_background is only a patch 9, so it is not very interesting in this respect. However, ?android:attr/listChoiceIndicatorMultiple indicates that an attribute based on the current topic (which is important for the implementation) will define the actual representation of the CheckBox.

Since listChoiceIndicatorMultiple is a topic attribute, you will find several ads for it – one for each topic (or none if it inherits from a parent). So it looks like the following (other attributes have been omitted for the sake of clarity):

So this is where the real magic happens: The actual appearance of the CheckBox is determined by the theme’s attribute listChoiceIndicatorMultiple. Now, the phenomenon you see is easy to explain: Because the look is based on the theme (and not on the style, because it’s just an empty definition) and you inherited it from Theme.Holo, you always get a checkbox that matches the theme.

Now, if you want to change the look of your CheckBox for the Holo.Light version, you need to take a copy of these sources, add them to your local sources and use a custom style to apply them.

Regarding your second question:

You can also define styles for individual widgets if you want to define a style for an application ?

Absolutely, and they overwrite any activity or style applicable.

Is it possible to define a theme (style with images) in the
widget? (…) Can this selector be used: link?

Update :

Let me start by saying that you should not rely on Android’s internal resources. There’s a reason why you can’t access the namespace internally.

However, the system resources can be accessed by searching them by name. Consider the following code fragment:

int id = Resources.getSystem().getIdentifier(btn_check_holo_light, drawable, android);
((CheckBox) findViewById( ;

The first line actually gives the ID of the rendered source btn_check_holo_light. Since we have already determined that it is the button picker that determines the appearance of the checkbox, we can define it as a button that can be drawn on the widget. The result is a CheckBox with the appearance of the Holo.Light version, no matter which theme/style you have defined in the application, activity or widget in the xml. Since this will only configure the drawn button, you will have to use other styles, such as B. for the appearance of the text, adjusted manually.

The result is displayed below the screenshot. The top box uses the method described above (I manually set the xml text in black), and the second box uses the standard holo-style theme (not luminous, so not bright).

The screenshot shows the result

Update2 :

With the introduction of the v22.1.0 support library, everything has become much easier! Quote from the release notes (emphasis added):

Lollipop has added the ability to replace a view level theme with the XML attribute android:theme – incredibly useful for things like dark action bars on light events. Now AppCompat enables the use of android:theme for toolbars (replacing the previous app:theme support) and, even better, brings android:theme support to all views on devices with API 11+.

In other words: You can now apply a theme to each view, which greatly simplifies the first task: All you have to do is specify the theme you want to apply to the corresponding view. That is, in the context of the original question, compare the following results:

The first check box is designed as if it were used in a dark theme, the second as if it were used in a light theme, regardless of the actual theme setting of your activity or application.

Of course, you should stop using the caveat and use hardware instead.

Solution 2:

Maybe that’s enough for you.

xml sth.


For your reference, just get over here

Solution 3:

The right way is to design the equipment:



It incorporates the hardware animation into Lollipop+.

Solution 4:

Maybe you want something like:

Note that the element textColor.

Solution No 5:

In the previous answer, also in the section… you might need it:

Good luck!

android checkbox drawable,android checkbox style programmatically,android checkbox custom drawable,android custom checkbox,android-checkbox color,android checkbox set checked,android material checkbox style,android checkbox size,multiple checkbox in android example,circular checkbox android,android checkbox padding

You May Also Like

Import Google Play Services library in Android Studio –

Development issue/problem: I have an Android project that is fully developed in…

7 Ideas For Popular Blogging Trends 2021

Are you planning to start a blog in 2021? A blog is…

WhatsApp call not connecting – How to fix it

WhatsApp is one of the most popular instant messaging apps in the…

How to get Modded Kik (Ultimate Mods Guide) 2021

Custom KiK is becoming increasingly popular, because with over 100 million downloads,…