Android Resource Learning Summary

Source: Internet
Author: User

When using the Android SDK for UI development, although you can also use pure code to complete, but that method for me just learning Android for the API still do not understand, can be similar to VB, MFC as graphic development of nature is the most appropriate. Fortunately Android also provides this way, in the Android project file specifically has a res directory for storage resources, the resources under the directory can be visualized editing, writing good resources through AAPT (Android assetpackaging Tools) tool to automatically generate the R.java resource index file under the Gen directory, and then use the index to invoke the resource in the Java code and XML resource file.

Android provides such a convenient resource structure, if you want to use it, or to have a deep understanding of him to be able to, the following is a brief summary of the study of Android resources to review and organize a few questions

Android Resource directory structure problem?

What types of resources do Android resources support, their specific syntax and usage rules?

1, the Resource directory structure

Android Resource Directory structure

Android Resources In addition to the assets directory is the same as the RES, other resources are placed under the res/directory, the directory below the resource folder is not arbitrarily named, you need to follow strict specifications, otherwise compiled generated R.java will be reported similar to "Invalidresource Directory Name * * "error and cause R.java to fail automatically.

Common default directories and corresponding resource types are listed in the SDK help and are briefly summarized below

Catalog Directory

Resource type Resource Types

Res/animator

Storing XML files that define the property animations (Android 3.0 new defined animation framework)

res/anim/

Stores an XML file that defines a motion tween (tweened animation) or frame-wise animation (frame by frame animation). (This directory can also hold the XML file that defines the property animations, but it is better to store separately)

res/raw/

Store any files that are copied directly to the device. They do not need to be compiled and added to the compressed file generated by your application compilation. To use these resources, you can call Resources.openrawresource (), which is the ID of the resource, which is r.raw. somefilename.

res/drawable/

Store bitmap files that can be converted to drawing resources (drawable Resource) (suffix. png,. 9.png,. jpg,. gif image file) or XML file that defines the drawing resource

res/color/

Stores an XML file that defines a color state list resource (a Resource)

res/layout/

Storing XML files that define the layout of the user interface

res/menu/

Storing an XML file that defines the Application menu resource

res/values/

Storing XML files that define multiple types of resources

The types of these resources can be string, data, color, size, style, and so on, detailed later

res/xml/

Stores arbitrary XML files that can be read at run time by calling Resources.getxml ()

The specific meaning of each directory, refer to the bottom connection

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

Folder naming rules in resource folders

Http://bbs.9ria.com/thread-238409-1-1.html

Android Resource Learning Summary

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.