Android creates resources for different languages and hardware

Source: Internet
Author: User
An important reason for external resources is Android Dynamic Resource selection mechanism.

 

Using the structure described below, you can create different resource values for the specified language, region, and hardware configurationAndroidThe system dynamically selects when running.

 

This allows you to create user interfaces for specific languages, regions, and hardware without changing yourCode.

 

In/ResSet a parallel folder under the folder to set the resources for selection, use"-"Delimiter to specify the applicationProgramSupported conditions.

 

The following hierarchical example shows the folder structure, including the default string value, the French string value, and the additional French string value for the Canadian region.

 

Project/

Res/

Values/

Strings. xml

Values-fr/

Strings. xml

Values-fr-RCA/

Strings. xml

 

The following list shows the identifiers you can use to customize the resource file name:

volumes language two lower-case ISO 639-1 language code (for example, en )

Bytes Region                         Lowercase" R ", Followed by two uppercase ISO 20176-1- α -2 Language code

 (For example,Rus,RGB)

Bytes Screen direction               " Port "( Portrait )," Land "( Landscape ),

 "Square"(Square)

volumes screen pixel density pixel in 1 inch ( DPI ) (for example, 92 DPI , 108 DPI )

volumes touch screen type " notouch "," stylus "," finger "

volumes keyboard display " keysexposed "or" keyshidden "

BytesKeyboard Input type    "Nokeys","Qwerty","12key"

Bytes UI Navigation type         " Notouch "," DPAD "," Trackball "," Wheel "

BytesScreen Resolution          Maximum screen size (pixels) (for example,320x240)

 

You can specify multiple identifiers for any resource type.-"Separator. Any combination is supported, but they must be used in the order given in the list, and each type of identifier cannot exceed1.

 

The following example showsDrawableValid and invalid folder names of resources.

 

Bytes Valid:

Drawable-en-Rus

Drawable-en-keyshidden

Drawable-land-notouch-nokeys-320x240

Bytes Invalid:

Drawable-Rus-en (Wrong order)

Drawable-Rus-ruk (A single type of identifier has multiple values)

 

WhenAndroidWhen a resource is obtained at runtime, it will find the most matched among the available resources. Starting from the list of folders (the folder contains the required values,AndroidSelect the folder with the most matching identifier. If the two folders match as many as possible, the matching identifiers in the above list are used as the basis for deciding the victory.

 

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.