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 4542394
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:23:04+00:00 2026-05-21T15:23:04+00:00

How do you change the color contrast of text when the background changes? for

  • 0

How do you change the color contrast of text when the background changes? for example If I was to have a black background, black text would not be visible.

  • 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-21T15:23:04+00:00Added an answer on May 21, 2026 at 3:23 pm

    This might be helpful: http://developer.android.com/guide/topics/resources/color-list-resource.html

    It is a way you can set a color that will change based on certain circumstances.

    For example, say you have a TextView that you want to have white text while it is enabled and black text when it is disabled. You can set that up in a xml file using the references in the link above, and then in your xml layout where you define the TextView set the android:textColor to @color/my_text_color. (my_text_color being the xml color list file you created)

    Then, as the TextView changes from enabled to disabled (or whatever you end up setting up in the xml file) the color will change automatically as well.

    That’s one way to do it. However, you might want to try to clarify what you are looking for as it isn’t perfectly clear in your question.

    Update

    After Matt’s comment, here is a method you could use to get an inverted color value. There is probably a better way but this should work.

    private int getInverseColor(int color){
        int red = Color.red(color);
        int green = Color.green(color);
        int blue = Color.blue(color);
        int alpha = Color.alpha(color);
        return Color.argb(alpha, 255-red, 255-green, 255-blue);
    }
    

    You could programmaticly get the color int from a view such as a TextView using one of the getTextColor() methods. You may have to tinker with a Color State List like I linked to above to get the color you want. Then pass that color to the method above to get the inverted color int and set it with one of the setTextColor() methods.

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

Sidebar

Related Questions

I have some text and I want it to change color in a manner
Is there any way to change text color in eclipse console? I am not
I want to change the background color of a custom view. I have a
How do I change text color using flash actionscript 2?
How can I change a color of some part of treenode Text ? For
I want to change color of text written in JTextArea . For e.g. I
Is it possible to change color of navigationItem.prompt?? self.navigationItem.prompt = @What would you like
Le Code (without background): http://jsfiddle.net/SP6ny/ (colors changed for extra contrast) Basically I have LI
How can i change color of just specific part of the label.text in visual
How to change color of the text in TextView on hover like in css

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.