Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6824825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:56:53+00:00 2026-05-26T21:56:53+00:00

I have an Android astronomy app where I need to tint the UI reddish

  • 0

I have an Android astronomy app where I need to tint the UI reddish for use at night. Although I have a scheme that works well for many (most??) UI elements, I’m having trouble with the CompoundButtons: CheckBox and RadioButton.

The basic idea is to retrieve the Drawable for the UI element and if it has one to set a color filter on it. My problem is finding the appropriate Drawable for the compound buttons. I would think that getCompoundDrawables() would be what I’d need, but the returned array for the 4 drawables always contains nulls for the 4 elements.

Here is the recursive code I call on the top level view to try to colorize the UI elements.

public static void setNightVisionBkg( View view )
{
    if ( view instanceof ViewGroup )
    {
        Drawable drawable = view.getBackground();
        if ( drawable != null )
            drawable.setColorFilter( 0xFFAA0000, PorterDuff.Mode.MULTIPLY );

        ViewGroup group = (ViewGroup) view;
        int numChildren = group.getChildCount();
        for ( int i = 0; i < numChildren; i++ )
        {
            View v = group.getChildAt( i );
            Drawable d = v.getBackground();
            if ( d != null )
                d.setColorFilter( 0xFFAA0000, PorterDuff.Mode.MULTIPLY );

            if ( v instanceof ViewGroup )
            {
                setNightVisionBkg( (ViewGroup) v );
            }
            else if (v instanceof CompoundButton)
            {
                CompoundButton compBtn = (CompoundButton)v;
                Drawable drawables[] = compBtn.getCompoundDrawables();
                for (int j = 0; j < drawables.length; j++)
                if (drawables[j] != null)
                {
                    drawables[j].setColorFilter( 0xFFAA0000, PorterDuff.Mode.MULTIPLY );
                }
            }
        }
    }
}

Note that it is the latter part where it is getting the Drawables for the CompoundButton that fails to work (all drawables are null).

Any thoughts on how to do this? I know I could set my own custom drawables, but I’d prefer to use the standard ones and just set a colorFilter if possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:56:53+00:00Added an answer on May 26, 2026 at 9:56 pm

    I solved my problem in a slightly different way. Ended up subclassing CheckBox (and RadioButton). In the subclass I override:

    protected boolean verifyDrawable( Drawable drawable )
    

    and in this method I set the colorFilter on the drawable. Works great.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have android application that I need to debug using eclipse. When I right
I have android app that talks to server and syncs some data int SQLite
I have an Android app that looks absolutely horrible if the user sets their
I have an Android app that I would like to convert to an Android
I have a MySQL Database on my server. I need my android app to
I have android app which works fine. And now I want to add some
I have an Android application that uses the well known Strategies for Legacy Applications
I'm helping a friend create an android app that will have screens with lists
I have android.permission.READ_OWNER_DATA but I can't find any reliable code that would explain how
I have android device with root and i try to implement some small app.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.