0% found this document useful (0 votes)
28 views3 pages

Add App Resources

The document discusses how to add different types of resources to an Android app project in Android Studio. It explains that app resources like bitmaps and layouts are organized into type-specific directories within the res/ folder. It provides instructions for adding an XML resource file or resource directory to a project. For XML files, the steps are to select the file type and name, resource type, and source set. For directories, the steps are similar but for selecting the directory name and type instead of a file. It also provides links to pages for adding other specific resource types like strings, bitmaps, and vectors.

Uploaded by

senze_shin3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views3 pages

Add App Resources

The document discusses how to add different types of resources to an Android app project in Android Studio. It explains that app resources like bitmaps and layouts are organized into type-specific directories within the res/ folder. It provides instructions for adding an XML resource file or resource directory to a project. For XML files, the steps are to select the file type and name, resource type, and source set. For directories, the steps are similar but for selecting the directory name and type instead of a file. It also provides links to pages for adding other specific resource types like strings, bitmaps, and vectors.

Uploaded by

senze_shin3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Android Developers

Add App Resources


App resources such as bitmaps and layouts
are organized into type-specic directories

Add an XML Resource File


(#add_an_xml_resource_le)

inside each module's res/ directory. You can

Add a Resource Directory

also add alternative versions of each le that

(#add_a_resource_directory)

that are optimized for different device


congurations (such as a high-res version of a
bitmap for high-density screens).
Android Studio helps you add new resources and alternative resources in several
ways, depending on the type of resource you want to add. This page describes how
to add generic XML les or resource directories to your project. You might instead
want to see the following pages for information about other resource types:
To add layout les, see Build a UI with Layout Editor (https://developer.android.com/studio
/write/layout-editor.html).

To add string les, see Localize the UI with Translations Editor


(https://developer.android.com/studio/write/translations-editor.html).

To add bitmaps, see Create App Icons with Image Asset Studio
(https://developer.android.com/studio/write/image-asset-studio.html).

To add SVG les, see Add Multi-Density Vector Graphics (https://developer.android.com


/studio/write/vector-asset-studio.html).

For information about how to reference the resources from your app code, see
Providing Resources (https://developer.android.com/guide/topics/resources/providing-resources.html).

Add an XML Resource File


Although the pages linked above describe workows that are customized to each
type of resource, you can add any XML resource le by following these steps:
1. Click the target app module in the Project window (while in either the Android or
Project view), and then select File > New > Android resource le.

2. Fill in the details in the dialog:


File name: Type the name for the XML le (does not require the .xml sufx).
Resource type: Select the type of resource you want to create.
Root element: If applicable, select the root XML element for the le. Some
resource types support only one type of root element, so depending on the
type selected above, this might not be editable.
Source set: Select the source set (https://developer.android.com/studio/build
/index.html#sourcesets)

where you want to save the le.

Directory name: The directory must be named in a way that's specic to the
resource type and conguration qualiers. So you should not edit this unless
you want to add conguration qualiers to the directory name by hand (see
Available qualiers instead).
Available qualiers: Instead of typing conguration qualiers for your layout
directory, you can add them by clicking a qualier from the list on the left, and
then clicking Add

3. Once you've added all the qualiers you want, click OK.
Tip: Right-click an existing resource directory within the res folder and select
New >

resource le. This opens a simplied version of the New Resource

File dialog that's specic to your desired resource type.

Add a Resource Directory

If you need to add a new resource directory, follow these steps:


1. Click the target app module in the Project window, and then select File > New >
Android resource directory.

2. Fill in the details in the dialog:


Directory name: The directory must be named in a way that's specic to the
resource type and combination of conguration qualiers. So you should not
edit this unless you want to add conguration qualiers to the directory name
by hand (use Available qualiers instead).
Resource type: Select the type of resource you want to create.
Source set: Select the source set where you want the layout.
Available qualiers: Instead of typing conguration qualiers for your layout
directory, you can add them by clicking a qualier from the list on the left, and
then clicking Add

3. Once you've added all the qualiers you want, click OK.

You might also like