Application Resources of Android)

Source: Internet
Author: User

When you write a program, you should get used to the resources required by some programs, such as examples and strings, which are separated and independently stored outside your program code, in this way, you can maintain these resource files independently. The resource file is independent of the Code, which allows you to provide more optional resources for the program to support some special device configurations, such as different languages and different screen sizes. As more and more Android devices start to support different configurations, this becomes more and more important. To make these Android devices compatible with various configurations, you must organize the res/directory under your project and manage resources by group based on the type and configuration.

 

 

For any type of resources, you can specify default and multiple optional resources for your program:

L The default (default) resources should be those that can be used when the device configuration is ignored or when there are no other alternative resources that can match the current configuration.

L alternative resources are the resources you set for specific configurations. A specific configuration corresponds to a group of specific resources, and then adds an appropriate configuration qualifier to the resource folder as the name.

(Note: a specific set of resources is a resource folder under your project directory. The layout folder res/layout is used)

 

For example, if your default UI layout is saved in the res/layout directory, you may need to set another UI layout to be saved in the res/layout-land/directory, it is used when your screen is landscape. Android automatically calls an appropriate resource by matching the current configuration information of the device to the name in your resource file directory.

 

Figure 1. Both devices use default Resources

Figure 2. Two different device configurations, one with alternative resources

 

Figure 1 shows how a set of default resources of an application are applied to different device configurations without any available alternative resources. Figure 2 shows that the same application has a set of alternative resources and each resource is limited to one device configuration, the two device configurations use different resources.

 

The above information only describes how application resources are applied on Android. The following documents provide a complete guide on how to organize and manage resources in your application, how to specify alternative resources, and how to use them in your program:

 

Providing Resources

This document describes what resource files you can use in your application, where these resource files are stored separately, and how to create Replaceable Resources for specific device configurations.

Accessing Resources

This document describes how to use the resources you provide, or how to reference resource files through your program code or from other XML type resource files.

Handling Runtime Changes

This document describes how to manage configurations when the Activity is running.

Localization

This document provides a bottom-up guidance on how to use replaceable resource files to initialize your application. Although this is only an alternative resource for a specific purpose, however, this is very important to attract more users.

Resource Types

This document describes various resource types that you can reference and describes the XML elements, attributes, and syntax of resources. For example, this reference will show you how to create a resource for the app's menus, images, colors, animations, and so on.

 

 

 

Reprinted please indicate the source: http://www.cnblogs.com/CodeGuy/

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.