Android common error No resource found that matches the given name

Source: Internet
Author: User

Today, when making a program, I think the background color of the TextView is not good, and I want to change the TextView color in the XML file. Because I have a colors.xml file in/res/values, use android:background= "@colors/lightyellow" in the XML file to set the background color of the TextView control to bright yellow. Result error: No resource found that matches the given name (at ' Background ' with value
' @colors/lightyellow '). Later on the online search solutions, saw an expert published the following ideas: You should always reference @color. If you reference @colors, then that ' d is good. Basically, when you type @color, it goes to/res/values and looks through the XML files there for a color value. Thus, the name of the XML file is actually arbitrary, as long as you have it in/res/values.
Consciousness is as long as your color file in the/res/values directory, regardless of the file name of your files, you have to use the @color method reference, probably because it only look at the XML file there is no <color></color> tag, do not look at the file name. By expert guidance, changed to android:background= "@color/lightyellow" the consequences of really no error, and successfully changed the background color of the TextView control.

Android common error No resource found that matches the given name

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.