Android-resource Introduction

Source: Internet
Author: User

1.Resource class

Resources getresources (): Contextwrapper, obtaining the current resources class

You can manipulate any resource file under the Res/folder.

Catalog: res/anim/

XML file for animation object

Catalog: res/drawalbe/

Picture file

Catalog: res/laout/

Layout file

Catalog: res/menu/

menu XML file that can generate menus

Catalog: res/values/

Array.xml: Defining Array Data

Colors.xml: Defines a string value for color drawalbe and colors. Get the resource using resources.getdrawable () and Resources.getcolor ()

Dimens.xml: Defines the dimension value (dimension). Resources.getdimension ()

Strings.xml: Defines string values, resources.getstring () and Resources.gettext ();

Styles.xml: Defines a Style object.

Catalog: res/xml/

Arbitrary XML files can be obtained at run time through the research Resources.getxml () method.

Catalog: res/raw/

You can copy any file directly to the device, usually a sound file. Resources.openrawresources (). The parameter is the ID of the resource.

2. In addition to the resource class to get a reference to a resource

In a Java file: r.xx.xxx or android.r.xx.xx reference resource

In the XML file: @xx/xx or @android:xx/xxx

3. Resource adaptation

In order to adapt the resources to different models, and user requirements (Chinese users, English users).

The "Res/values-zh" method represents a resource reference for a specific (zh: Chinese), and "-xxx" is a string added to the resource path that describes the specific condition of the resource.

Android-resource Introduction

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.