Android has four methods in the code to set the control background color (including RGB)

Source: Internet
Author: User

 
 
TextView tText = (TextView) findViewById (R. id. textv_name); // 1st types: tText. setTextColor (android. graphics. color. RED); // color class that comes with the system // 2nd types: tText. setTextColor (0xffff00ff); // 0xffffff00ff is int type data, grouped by 0x | ff | ff00ff, 0x indicates the color integer, ff indicates the transparency, and ff00ff indicates the color, note: Here, ffff00ff must be represented by 8 colors, and 6 colors such as ff00ff are not accepted. // Type 3rd: tText. setTextColor (android. graphics. color. parseColor (#87 CEFA); // use the Color class; // 4th types: tText. setTextColor (this. getResources (). getColor (R. color. red);/* Set it by obtaining the resource file. R. color. red can also be R. string. red or R. drawable. red, * Of course, the premise is that you need to configure the corresponding configuration file, such as (xml tag ):**

 
  
# FF0000

 

 
  
# FF0000

 

 
  
# FF0000

 */

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.