Android official documentation: (3) resources-3.1 Overview

Source: Internet
Author: User

You shoshould always externalize resources such as images and strings from your application code, so that you can maintain them independently. externalizing your resources also allows you to provide alternative resources that support specific device deployments such as different versions or screen sizes, which becomes extends important as more Android-powered devices become available with different events. in order to provide compatibility with different deployments, you must organize resources in your project'sres/Directory, using various sub-directories that group resources by type and configuration.

Figure 1.Two different devices, each using the default layout (the app provides no alternative layouts ).

Figure 2.Two different devices, each using a different layout provided for different screen sizes.

For any type of resource, you can specifyDefaultAnd multipleAlternativeResources for your application:

  • Default resources are those that shocould be used regardless of the device configuration or when there are no alternative resources that match the current configuration.
  • Alternative resources are those that you 've designed for use with a specific configuration. To specify that a group of resources are for a specific configuration, append an appropriate configuration qualifier to the directory name.

For example, while your default UI layout is saved inres/layout/Directory, you might specify a different layout to be used when the screen is in landscape orientation, by saving it inres/layout-land/Directory. Android automatically applies the appropriate resources by matching the device's current configuration to your resource directory names.

Figure 1 when strates how the system applies the same layout for two different devices when there are no alternative resources available. Figure 2 shows the same application when it adds an alternative layout resource for larger screens.

The following privileges ents provide a complete guide to how you can organize your application resources, specify alternative resources, access them in your application, and more:

Providing Resources
What kinds of resources you can provide in your app, where to save them, and how to create alternative resources for specific device deployments.
Accessing Resources
How to use the resources you 've provided, either by referencing them from your application code or from other XML resources.
Handling Runtime Changes
How to manage configuration changes that occur while your Activity is running.
Localization
A bottom-up guide to localizing your application using alternative resources. While this is just one specific use of alternative resources, it is very important in order to reach more users.
Resource Types
A reference of various resource types you can provide, describing their XML elements, attributes, and syntax. for example, this reference shows you how to create a resource for application menus, drawables, animations, and more.

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.