In the Code, set the TextView font color and textview font color.

Source: Internet
Author: User

In the Code, set the TextView font color and textview font color.

 

 

There are two common methods:

1. dimens In the res folder. xml, styles. xml or strings. add the <color name = "green"> #00ff00 </color> label to the xml file, or create a color in the res folder. xml file, add the root tag <resource> </resource> to the file, and then add the <color> note in the root tag. Then, you can set the tag in the Code as follows:

TextView. setTextColor (Context. getResources (). getColor (R. color. green ));

 

2. textView. setTextColor (0xff00ff00 );

Here, "0x" indicates that the value is an integer ff in hexadecimal notation. "ff" indicates that the transparency is not transparent. "00" indicates that the value is completely transparent. "00ff00" indicates that the value is green.

Note: In this method, the value after 0x must be 8 digits, transparency (2 bits) + color value (6 bits)

 


The text color in textview in android is invalid? Only the first one can display the color. Others are the default ones.

Check whether setEnabled (false) is set in the code)
 
Android development: how to set the text and background colors of textView statically and dynamically? Beginners do not know what to fill in details

Static is to fill in the attributes in the visualized Graphical Layout.
TextView1.TextColor (text color)
TextView1.Background (background color)
In @ android, all defined color values are automatically displayed.
For example, @ android: color/holo_blue_bright
Dynamic is set color in the program
Import android. graphics. Color;

TextView1.setTextColor (Color. RED );
TextView1.setBackgroundColor (Color. RED );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.