Gets the color value in RES/values/color and sets the background for the view.

Source: Internet
Author: User


We usually extract the colors displayed on the interface to RES/values/color, which facilitates the acquisition and management.

How can we get the color value in the color file and set the background color for iview.

First:

If you write this in color, <color name = "Item1"> # eed776 </color>

In this case, you should obtain the background color of the view.

View. setbackgroundcolor (context. getresources (). getcolor (R. color. Item1 ));

Because: View sets the background color, only eight color values are recognized.

Second

If you write this in the file, <color name = "Item1"> # ffeed776 </color>

FF indicates transparency

You can directly use

View. setbackgroundcolor (R. color. Item1 );


Third

You can directly use

<Span style = "font-family: simsun; font-size: 18px;"> <textview Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Android: background = "@ color/item0" Android: text = "color"/> </span>

Gets the color value in RES/values/color and sets the background for the view.

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.