Android Application resources-Overview

Source: Internet
Author: User

Application resources, slices, and strings should always be placed outside the code so that they can be maintained independently. When resources are put externally, you can also provide optional resources that support special device configurations, such as different languages or screen sizes. As Android supports more and more devices with different configurations, this feature of code and resource separation becomes increasingly important. To provide compatibility with different configurations, resources must be organized into the Res/directory of the project, and different types of configuration resources must be grouped using subdirectories.

For any type of resources, you can specify default resources and multiple optional resources for the application:

1. The default resource is the resource that is used when the device configuration is irrelevant or when there are no optional resources that match the current configuration.

2. Optional resources are the resources used to configure specific devices. For special configurations, you must specify a Resource Group and append an appropriate configuration qualifier to the directory name.

For example, if the default UI layout is saved in the Res/layout/directory, you can specify different la s for a horizontal screen and save them in the Res/Layout-land/directory. By matching the current configuration of the device with the Resource Directory, android can automatically apply suitable resources.

Figure 1 shows how the system applies the same layout to two different devices when there are no available resources. Figure 2 demonstrates the effect of an application when an optional layout resource is added to the screen device.

Figure 1. Two different devices with the default layout (no available layout resources)

 

Figure 2. Use different layout resources for different screen sizes for two different devices.

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.