Android Resource learning Summary: androidresource

Source: Internet
Author: User

Android Resource learning Summary: androidresource

 

Although the Android SDK can also be used for UI development, the method is for people who have just learned Android and do not understand the API, it is naturally most appropriate to perform graphical development like VB and MFC. Fortunately, Android also provides this method. In the Android project file, there is a res directory for storing resources. Resources under this directory can be visually edited, the compiled resources use the AAPT (Android AssetPackaging Tool) Tool to automatically generate the R. the java resource index file can be used to call resources in Java code and XML resource files.

Android provides such a convenient resource architecture. If you want to use it, you still need to have a deep understanding of it. Here are some questions about how to learn Android resources.

Android resource directory structure problems?

What types of resources are supported by Android resources, their specific syntax and usage rules?

1. Resource Directory structure

 

Android resource directory structure

In addition to the assets Directory, Android resources are stored in the res/directory. The resource folders under the directory are not named randomly and must follow strict rules, otherwise, the R. during java, an error message similar to "invalidresource directory name **" is reported, which causes the R. java Automatic Generation failed.

Common default directories and corresponding resource types are listed in the SDK help table. The simple excerpt is as follows:

Directory

Resource Types

Res/animator

Stores XML files that define property animations (new animation framework of android 3.0 ).

Res/anim/

Stores XML files that define tweened animation or frame by frame animation. (This directory can also store XML files defining property animations, but it is best to store them separately)

Res/raw/

Store any file that is directly copied to the device. They do not need to be compiled and are added to the compressed files generated by your application compilation. To use these Resources, you can call Resources. openRawResource (). The parameter is the resource ID, that is, R. raw.Somefilename.

Res/drawable/

Save the XML file that can be converted to a drawing Resource (the graphic file of Drawable resource.pdf (.png, .9.png,. jpg,. gif) or define the drawing Resource

Res/color/

Stores the XML file that defines the Color State List Resource.

Res/layout/

Stores XML files that define the user interface Layout

Res/menu/

Stores XML files that define Application menu Resources

Res/values/

Store XML files that define multiple types of resources

The types of these resources can be strings, Data, colors, dimensions, styles, etc.

Res/xml/

Store any XML file, which can be read by calling Resources. getXML () at runtime.

For more information about each directory, see connect

Http://www.jb51.net/article/37224.htm

 

Naming rules for folders in a resource folder Http://bbs.9ria.com/thread-238409-1-1.html

 

Android resource types and their simple application

Http://www.cnblogs.com/hnrainll/archive/2012/11/21/2781121.html

 

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.