Resources arethe additional files & static content that your code uses, such as bitmaps, layoutdefinitions, user interface strings, animation instructions, and more.

Bạn đang xem: Binary search là gì

You should always externalize tiện ích resources such as images & strings from yourcode, so that you can maintain them independently. You should also provide alternative sầu resources forspecific device configurations, by grouping them in specially-named resource directories. Atruntime, alokapidakaldim.com uses the appropriate resource based on the current configuration. Forexample, you might want khổng lồ provide a different UI layout depending on the screen size or differentstrings depending on the language setting.

Once you externalize your tiện ích resources, you can access themusing resource IDs that are generated in your project"s R class.This document shows you how to lớn group your resources in your alokapidakaldim.com project andprovide alternative sầu resources for specific device configurations, & then access them fromyour ứng dụng code or other XML files.

Grouping resource types

You should place each type of resource in a specific subdirectory of your project"sres/ directory. For example, here"s the tệp tin hierarchy for a simple project:

MyProject/ src/ MyActivity.java res/ drawable/ graphic.png layout/ main.xml info.xml mipmap/ ibé.png values/ strings.xmlAs you can see in this example, the res/ directory contains all the resources (insubdirectories): an image resource, two layout resources, mipmap/ directories for launchericons, and a string resource tệp tin. The resourcedirectory names are important & are described in table 1.

Note: For more information about using the mipmap folders, seeManaging Projects Overview.

Table 1. Resource directoriessupported inside project res/ directory.

Directory Resource Type
animator/ XML files that define propertyanimations.
anim/ XML files that define tweenanimations. (Property animations can also be saved in this directory, butthe animator/ directory is preferred for property animations to distinguish between the twotypes.)
color/ XML files that define a state danh mục of colors. See ColorState List Resource
drawable/

Bitmaps files (.png, .9.png, .jpg, .gif) or XML files thatare compiled inkhổng lồ the following drawable resource subtypes:

Bitmaps files Nine-Patches (re-sizable bitmaps) State lists Shapes Animation drawables Other drawables

See Drawable Resources.

mipmap/ Drawable files for different launcher inhỏ densities. For more information on managing launcher icons with mipmap/ folders, see Managing Projects Overview.
layout/ XML files that define a user interface layout. See Layout Resource.
menu/ XML files that define ứng dụng menus, such as an Options Menu, Context Menu, or SubMenu. See Menu Resource.
raw/

Arbitrary files khổng lồ save sầu in their raw khung. To open these resources with a rawInputStream, callResources.openRawResource() with the resource ID, which is R.raw.filename.

However, if you need access khổng lồ original file names and tệp tin hierarchy, you might considersaving some resources in the assets/ directory (instead of res/raw/). Files in assets/ aren"t given aresource ID, so you can read them only using AssetManager.

values/

XML files that contain simple values, such as strings, integers, và colors.

Whereas XML resource files in other res/ subdirectories define a single resourcebased on the XML filename, files in the values/ directory describe multiple resources.For a tệp tin in this directory, each child of the element defines a singleresource. For example, a element creates anR.string resource and a element creates an R.colorresource.

Because each resource is defined with its own XML element, you can name the filewhatever you want and place different resource types in one file. However, for clarity, you mightwant to place quality resource types in different files. For example, here are some filenameconventions for resources you can create in this directory:

See String Resources, Style Resource, và More Resource Types.

xml/ Arbitrary XML files that can be read at runtime by calling Resources.getXML(). Various XML configuration filesmust be saved here, such as a searchable configuration.
font/ Font files with extensions such as .ttf, .otf, or .ttc, or XML files that include a element. For more information about fonts as resources, go to Fonts in XML.

Caution: Never save resource files directly inside theres/ directory—it causes a compiler error.

For more information about certain types of resources, see the Resource Types documentation.

The resources that you save in the subdirectories defined in table 1 are your "default"resources. That is, these resources define the default thiết kế và nội dung for your phầm mềm.However, different types of alokapidakaldim.com-powered devices might hotline for different types of resources.For example, if a device has a larger than normal screen, then you should providedifferent layout resources that take advantage of the extra screen space. Or, if a device has adifferent language setting, then you should provide different string resources that translate thetext in your user interface. To provide these different resources for different deviceconfigurations, you need to provide alternative sầu resources, in addition to lớn your defaultresources.

Providing alternative sầu resources

Almost every ứng dụng should provide alternative resources to lớn tư vấn specific deviceconfigurations. For instance, you should include alternative sầu drawable resources for differentscreen densities & alternative sầu string resources for different languages. At runtime, alokapidakaldim.comdetects the current device configuration và loads the appropriateresources for your phầm mềm.

*

Figure 1. Two different devices, each using different layout resources.

To specify configuration-specific alternatives for a mix of resources:

Create a new directory in res/ named in the khung -. is the directory name of the corresponding defaultresources (defined in table 1). is a name that specifies an individual configurationfor which these resources are khổng lồ be used (defined in table 2).

You can appkết thúc more than one . Separate eachone with a dash.

Caution: When appending multiple qualifiers, you mustplace them in the same order in which they are listed in table 2. If the qualifiers are orderedwrong, the resources are ignored.

Save the respective sầu alternative resources in this new directory. The resource files must benamed exactly the same as the default resource files.

For example, here are some default and alternative sầu resources:

res/ drawable/ inhỏ.png background.png drawable-hdpi/ inhỏ.png background.pngThe hdpi qualifier indicates that the resources in that directory are for devices with ahigh-density screen. The images in each of these drawable directories are sized for a specificscreen mật độ trùng lặp từ khóa, but the filenames are exactlythe same. This way, the resource ID that you use to lớn reference the ibé.png or background.png image is always the same, but alokapidakaldim.com selects theversion of each resource that best matches the current device, by comparing the deviceconfiguration information with the qualifiers in the resource directory name.

Caution: When defining an alternative sầu resource, make sure youalso define the resource in a default configuration. Otherwise, your phầm mềm might encounter runtimeexceptions when the device changes a configuration. For example, if you add a string to lớn onlyvalues-en & not values, your app might encounter aResource Not Found exception when the user changes the mặc định system language.

alokapidakaldim.com supports several configuration qualifiers & you canadd multiple qualifiers lớn one directory name, by separating each qualifier with a dash. Table 2lists the valid configuration qualifiers, in order of precedence—if you use multiplequalifiers for a resource directory, you must add them to lớn the directory name in the order theyare listed in the table.

Table 2. Configuration qualifiernames.

Configuration Qualifier Values Description
MCC and MNC Examples: mcc310 mcc310-mnc004 mcc208-mnc00 etc.

The Mobile country code (MCC), optionally followed by điện thoại network code (MNC) from the SIM card in the device. For example, mcc310 is U.S. on any carrier, mcc310-mnc004 is U.S. on Verizon, & mcc208-mnc00 is France on Orange.

If the device uses a radio connection (GSM phone), the MCC và MNC values come from the SIM thẻ.

You can also use the MCC alone (for example, to lớn include country-specific legalresources in your app). If you need lớn specify based on the language only, then use thelanguage and region qualifier instead (discussed next). If you decide khổng lồ use the MCC andMNC qualifier, you should vày so with care and demo that it works as expected.

Also see the configuration fields mcc, & mnc, which indicate the current di động country code& sản phẩm điện thoại network code, respectively.

Language & region Examples: en fr en-rUS fr-rFR fr-rCA b+en b+en+US b+es+419

The language is defined by a two-letter ISO 639-1 language code, optionally followed by a two letter ISO 3166-1-alpha-2 region code (preceded by lowercase r).

The codes are not case-sensitive; the r prefix is used to lớn distinguish the region portion. You cannot specify a region alone.

alokapidakaldim.com 7.0 (API màn chơi 24) introduced support for BCPhường 47 language tags, which you can use khổng lồ qualify language- và region-specific resources. A language tag is composed from a sequence of one or more subtags, each of which refines or narrows the range of language identified by the overall tag. For more information about language tags, see Tags for Identifying Languages.

To use a BCP. 47 language tag, concatenate b+ and a two-letter ISO 639-1 language code, optionally followed by additional subtags separated by +. The language tag can change during the life of your ứng dụng if the users change their language in the system settings. See Handling Runtime Changes for information abouthow this can affect your tiện ích during runtime.

See Localization for a complete guide khổng lồ localizingyour app for other languages.

Also see the getLocales() method, which provides the defined list of locales. This menu includes the primary locale.

Layout Direction ldrtl ldltr

The layout direction of your phầm mềm. ldrtl means "layout-direction-right-to-left". ldltr means "layout-direction-left-to-right" and is the default implicit value.

This can apply to any resource such as layouts, drawables, or values.

For example, if you want lớn provide some specific layout for the Arabic language & some generic layout for any other "right-to-left" language (lượt thích Persian or Hebrew) then you would have sầu the following:

res/ layout/ main.xml (Default layout) layout-ar/ main.xml (Specific layout for Arabic) layout-ldrtl/ main.xml (Any "right-to-left" language, except for Arabic, because the "ar" language qualifier has a higher precedence)

Note: To enable right-to-left layout features for your phầm mềm, you must set supportsRtl khổng lồ "true" & mix targetSdkVersion khổng lồ 17 or higher.

Added in API cấp độ 17.

smallestWidth swdp Examples: sw320dp sw600dp sw720dp etc.

The fundamental size of a screen, as indicated by the shorthử nghiệm dimension of the available screen area. Specifically, the device"s smallestWidth is the shortest of the screen"s available height and width (you may also think of it as the "smallest possible width" for the screen). You can use this qualifier khổng lồ ensure that, regardless of the screen"s current orientation, your app"s has at least dps of width available for its UI.

For example, if your layout requires that its smallest dimension of screen area be at least 600 dp at all times, then you can use this qualifier to lớn create the layout resources, res/layout-sw600dp/. The system uses these resources only when the smallest dimension of available screen is at least 600dp, regardless of whether the 600dp side is the user-perceived height or width. The smallest width is a fixed screen size characteristic of the device; the device"s smallest width doesn"t change when the screen"s orientation changes.

Using smallest width to lớn determine the general screen kích cỡ is useful because width is often the driving factor in designing a layout. A UI will often scroll vertically, but have fairly hard constraints on the minimum space it needs horizontally. The available width is also the key factor in determining whether lớn use a one-pane layout for handsets or multi-pane layout for tablets. Thus, you likely care most about what the smallest possible width will be on each device.

The smallest width of a device takes inlớn tài khoản screen decorations & system UI. For example, if the device has some persistent UI elements on the screen that account for space along the axis of the smallest width, the system declares the smallest width lớn be smaller than the actual screen size, because those are screen pixels not available for your UI.

Some values you might use here for comtháng screen sizes:

3trăng tròn, for devices with screen configurations such as: 240x3đôi mươi ldpi (Qđồ họa handset) 320x480 mdpi (handset) 480x800 hdpi (high-mật độ trùng lặp từ khóa handset) 480, for screens such as 480x800 mdpi (tablet/handset). 600, for screens such as 600x1024 mdpi (7" tablet). 720, for screens such as 720x1280 mdpi (10" tablet).

When your phầm mềm provides multiple resource directories with different values for the smallestWidth qualifier, the system uses the one closest to lớn (without exceeding) thedevice"s smallestWidth.

Added in API màn chơi 13.

Also see the alokapidakaldim.com:requiresSmallestWidthDp attribute, which declares the minimum smallestWidth with whichyour app is compatible, and the smallestScreenWidthDp configuration field, which holds thedevice"s smallestWidth value.

For more information about designing for different screens và using thisqualifier, see the SupportingMultiple Screens alokapidakaldim.com guide.

Available width wdp Examples: w720dp w1024dp etc.

Specifies a minimum available screen width, in dp units at which the resource should be used—defined by the value. This configuration value changes when the orientation changes between landscape and portrait to lớn match the current actual width.

This is often useful to lớn determine whether to lớn use a multi-pane layout, because even on a tablet device, you often won"t want the same multi-pane layout for portrait orientation as you do for landscape. Thus, you can use this lớn specify the minimum width required for the layout, instead of using both the screen form size and orientation qualifiers together.

Xem thêm: Kí HiệU =)), :V Là Gì ? Tìm Hiểu Kí Hiệu V Trong Mọi Lĩnh Vực

When your app provides multiple resource directories with different values for this configuration, the system uses the one closest to lớn (without exceeding) the device"s current screen width. The value here takes into tài khoản screen decorations, so if the device has some persistent UI elements on the left or right edge of the display, it uses a value for the width that is smaller than the real screen kích cỡ, accounting for these UI elements & reducing the app"s available space.

Added in API màn chơi 13.

Also see the screenWidthDp configuration field, which holds the current screen width.

For more information about designing for different screens & using thisqualifier, see the SupportingMultiple Screens alokapidakaldim.com guide.

Available height hdp Examples: h720dp h1024dp etc.

Specifies a minimum available screen height, in "dp" units at which the resource should be used—defined by the value. This configuration value changes when the orientation changes between landscape và portrait khổng lồ match the current actual height.

Using this to define the height required by your layout is useful in the same way as wdp is for defining the required width, instead of using both the screen kích cỡ và orientation qualifiers. However, most apps won"t need this qualifier, considering that UIs often scroll vertically & are thus more flexible with how much height is available, whereas the width is more rigid.

When your ứng dụng provides multiple resource directories with different values for this configuration, the system uses the one closest khổng lồ (without exceeding) the device"s current screen height. The value here takes into lớn account screen decorations, so if the device has some persistent UI elements on the top or bottom edge of the display, it uses a value for the height that is smaller than the real screen kích thước, accounting for these UI elements and reducing the app"s available space. Screen decorations that aren"t fixed (such as a phone status bar that can be hidden when full screen) are not accounted for here, nor are window decorations like the title bar or action bar, so apps must be prepared to lớn giảm giá with a somewhat smaller space than they specify. Added in API cấp độ 13.

Also see the screenHeightDp configuration field, which holds the current screen height.

For more information about designing for different screens and using this qualifier, see the Supporting Multiple Screens alokapidakaldim.com guide.

Screen size small normal large xlarge small: Screens that are of similar form size to a low-mật độ trùng lặp từ khóa QVGA screen. The minimum layout kích thước for a small screen is approximately 320x426 dp units. Examples are Qđồ họa low-mật độ trùng lặp từ khóa and đồ họa high density. normal: Screens that are of similar kích thước khổng lồ a medium-density Hcard đồ họa screen. The minimum layout kích thước for a normal screen is approximately 320x470 dp units. Examples of such screens a WQcard VGA low-density, Hđồ họa medium-density, Wđồ họa high-mật độ trùng lặp từ khóa. large: Screens that are of similar form size khổng lồ a medium-mật độ trùng lặp từ khóa VGA screen. The minimum layout form size for a large screen is approximately 480x640 dp units. Examples are VGA & Wcard VGA medium-mật độ trùng lặp từ khóa screens. xlarge: Screens that are considerably larger than the traditional medium-mật độ trùng lặp từ khóa Hcard VGA screen. The minimum layout kích cỡ for an xlarge screen is approximately 720x960 dp units. In most cases, devices with extra-large screens would be too large khổng lồ carry in a pocket and would most likely be tablet-style devices. Added in API level 9.

Note: Using a kích thước qualifier does not imply that the resources are only for screens of that size. If you do not provide alternative sầu resources with qualifiers that better match the current device configuration, the system may use whichever resources are the best match.

Caution: If all your resources use a size qualifier that is larger than the current screen, the system will not use them và your app will crash at runtime (for example, if all layout resources are tagged with the xlarge qualifier, but the device is a normal-form size screen).

Added in API cấp độ 4.

See Supporting MultipleScreens for more information.

Also see the screenLayout configuration field,which indicates whether the screen is small, normal,or large.

Screen aspect long notlong long: Long screens, such as WQVGA, WVGA, FWcard đồ họa notlong: Not long screens, such as Qcard đồ họa, Hcard VGA, & card đồ họa

Added in API màn chơi 4.

This is based purely on the aspect ratio of the screen (a "long" screen is wider). Thisisn"t related khổng lồ the screen orientation.

Also see the screenLayout configuration field,which indicates whether the screen is long.

Round screen round notround round: Round screens, such as a round wearable device notround: Rectangular screens, such as phones or tablets

Added in API màn chơi 23.

Also see the isScreenRound() configurationmethod, which indicates whether the screen is round.

Wide màu sắc Gamut widecg nowidecg widecg: Displays with a wide color gamut such as Display P3 or AdobeRGB nowidecg: Displays with a narrow color gamut such as sRGB

Added in API level 26.

Also see the isScreenWideColorGamut() configuration method, which indicates whether the screen has a wide color gamut.

High Dynamic Range (HDR) highdr lowdr highdr: Displays with a high-dynamic range lowdr: Displays with a low/standard dynamic range

Added in API cấp độ 26.

Also see the isScreenHdr() configuration method, which indicates whether the screen has a HDR capabilities.

Screen orientation port l& port: Device is in portrait orientation (vertical) land: Device is in landscape orientation (horizontal)

This can change during the life of your app if the user rotates thescreen. See Handling Runtime Changes for information abouthow this affects your ứng dụng during runtime.

Also see the orientation configuration field,which indicates the current device orientation.

UI mode car desk television appliance watch vrheadset car: Device is displaying in a oto doông chồng desk: Device is displaying in a desk doông xã television: Device is displaying on a television, providing a "ten foot" experience where its UI is on a large screen that the user is far away from, primarily oriented around DPAD or other non-pointer interaction appliance: Device is serving as an appliance, with no display watch: Device has a display và is worn on the wrist vrheadset: Device is displaying in a virtual reality headphối

Added in API level 8, television added in API 13, watch added in API đôi mươi.

For information about how your tiện ích can respond when the device is inserted inkhổng lồ or removed from a doông chồng, read Determiningand Monitoring the Docking State and Type.

This can change during the life of your app if the user places the device in adock. You can enable or disable some of these modes using UiModeManager. See Handling Runtime Changes forinformation about how this affects your tiện ích during runtime.

Night mode night notnight night: Night time notnight: Day time

Added in API cấp độ 8.

This can change during the life of your app if night mode is left inauto mode (default), in which case the mode changes based on the time of day. You can enableor disable this mode using UiModeManager. See Handling Runtime Changes for information about how this affects yourapp during runtime.

Screen pixel density (dpi) ldpi mdpi hdpi xhdpi xxhdpi xxxhdpi nodpi tvdpi anydpi nnndpi ldpi: Low-density screens; approximately 120dpi. mdpi: Medium-mật độ trùng lặp từ khóa (on traditional HVGA) screens; approximately160dpi. hdpi: High-mật độ trùng lặp từ khóa screens; approximately 240dpi. xhdpi: Extra-high-mật độ trùng lặp từ khóa screens; approximately 320dpi. Added in APILevel 8 xxhdpi: Extra-extra-high-mật độ trùng lặp từ khóa screens; approximately 480dpi. Added in APILevel 16 nodpi: This can be used for bitmaps resources that you don"t want to lớn be scaledlớn match the device density. tvdpi: Screens somewhere between mdpi and hdpi; approximately 213dpi. This isn"tconsidered a "primary" density group. It is mostly intended for televisions & mostapps shouldn"t need it—providing mdpi & hdpi resources is sufficient for most apps andthe system scales them as appropriate. Added in API Level 13 nnndpi: Used to lớn represent non-standard densities, where nnn is a positive integer screen mật độ trùng lặp từ khóa. This shouldn"t be used in most cases. Use standard mật độ trùng lặp từ khóa buckets, which greatly reduces the overhead of supporting the various device screen densities on the market.

There is a 3:4:6:8:12:16 scaling ratio between the six primary densities (ignoring thetvdpi density). So, a 9x9 bitbản đồ in ldpi is 12x12 in mdpi, 18x18 in hdpi, 24x24 in xhdpi and so on.

If you decide that your image resources don"t look good enough on a television orother certain devices và want khổng lồ try tvdpi resources, the scaling factor is 1.33*mdpi. Forexample, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi.

Note: Using a mật độ trùng lặp từ khóa qualifier doesn"t imply that theresources are only for screens of that density. If you don"t provide alternativeresources with qualifiers that better match the current device configuration, the system may usewhichever resources are the best match.

See Supporting MultipleScreens for more information about how khổng lồ handle different screen densities và how alokapidakaldim.commight scale your bitmaps to fit the current density.

Touchscreen type notouch finger notouch: Device doesn"t have sầu a touchscreen. finger: Device has a touchscreen that is intended khổng lồ be used through direction interaction of the user"s finger.

Also see the touchscreen configuration field,which indicates the type of touchscreen on the device.

Keyboard availability keysexposed keyshidden keyssoft keysexposed: Device has a keyboard available. If the device has asoftware keyboard enabled (which is likely), this may be used even when the hardware keyboardisn"t exposed to the user, even if the device has no hardware keyboard. If no softwarekeyboard is provided or it"s disabled, then this is only used when a hardware keyboard isexposed. keyshidden: Device has a hardware keyboard available but it ishidden and the device does not have a software keyboard enabled. keyssoft: Device has a software keyboard enabled, whether it"svisible or not.

If you provide keysexposed resources, but not keyssoftresources, the system uses the keysexposed resources regardless of whether akeyboard is visible, as long as the system has a software keyboard enabled.

This can change during the life of your ứng dụng if the user opens a hardwarekeyboard. See Handling Runtime Changes for information about howthis affects your phầm mềm during runtime.

Also see the configuration fields hardKeyboardHidden và keyboardHidden, which indicate the visibility of a hardwarekeyboard & the visibility of any kind of keyboard (including software), respectively.

Primary text đầu vào method nokeys qwerty 12key nokeys: Device has no hardware keys for text đầu vào. qwerty: Device has a hardware qwerty keyboard, whether it"s visible lớn theuseror not. 12key: Device has a hardware 12-key keyboard, whether it"s visible khổng lồ the useror not.

Also see the keyboard configuration field,which indicates the primary text input method available.

Navigation key availability navexposed navhidden navexposed: Navigation keys are available to lớn the user. navhidden: Navigation keys aren"t available (such as behind a closedlid).

This can change during the life of your phầm mềm if the user reveals the navigationkeys. See Handling Runtime Changes forinformation about how this affects your tiện ích during runtime.

Also see the navigationHidden configurationfield, which indicates whether navigation keys are hidden.

Primary non-touch navigation method nonav dpad trackball wheel nonav: Device has no navigation facility other than using thetouchscreen. dpad: Device has a directional-pad (d-pad) for navigation. trackball: Device has a trackball for navigation. wheel: Device has a directional wheel(s) for navigation (uncommon).

Also see the navigation configuration field,which indicates the type of navigation method available.

Platform Version (API level) Examples: v3 v4 v7 etc.

The API cấp độ supported by the device. For example, v1 for API level1 (devices with alokapidakaldim.com 1.0 or higher) & v4 for API cấp độ 4 (devices with alokapidakaldim.com1.6 or higher). See the alokapidakaldim.com API levels document for more informationabout these values.

Note: Some configuration qualifiers have sầu been added since alokapidakaldim.com1.0, so not all versions of alokapidakaldim.com support all the qualifiers. Using a new qualifier implicitlyadds the platform version qualifier so that older devices are sure to lớn ignore it. For example, usinga w600dp qualifier automatically includes the v13 qualifier, becausethe available-width qualifier was new in API cấp độ 13. To avoid any issues, always include a mix ofdefault resources (a phối of resources with no qualifiers). For more information, see thesection about Providing the Best Device Compatibility withResources.

Qualifier name rules

Here are some rules about using configuration qualifier names:

You can specify multiple qualifiers for a single phối of resources, separated by dashes. Forexample, drawable-en-rUS-lvà applies lớn US-English devices in landscapeorientation. The qualifiers must be in the order listed in table 2. Forexample: Wrong: drawable-hdpi-port/ Correct: drawable-port-hdpi/ Alternative sầu resource directories cannot be nested. For example, you cannot haveres/drawable/drawable-en/. Values are case-insensitive sầu. The resource compiler converts directory names to lớn lower case before processing khổng lồ avoid problems on case-insensitive tệp tin systems. Any capitalization in the names is only to lớn benefit readability.

After you save alternative resources inkhổng lồ directories named withthese qualifiers, alokapidakaldim.com automatically applies the resources in your phầm mềm based on thecurrent device configuration. Each time a resource is requested, alokapidakaldim.com checks for alternativeresource directories that contain the requested resource tệp tin, then finds thebest-matching resource (discussed below). If there are no alternative resources that matcha particular device configuration, then alokapidakaldim.com uses the corresponding default resources (thephối of resources for a particular resource type that doesn"t include a configurationqualifier).

Creating alias resources

When you have a resource that you"d like to use for more than one deviceconfiguration (but don"t want khổng lồ provide as a mặc định resource), you don"t need khổng lồ put the sameresource in more than one alternative sầu resource directory. Instead, you can (in some cases) create analternativeresource that acts as an alias for a resource saved in your default resource directory.

Xem thêm: Túc Từ Là Gì - Có Bao Nhiêu Loại Túc Từ Trong Tiếng Anh

Note: Not all resources offer a mechanism by which you cancreate an alias to lớn another resource. In particular, animation, menu, raw, and other unspecifiedresources in the xml/ directory don"t offer this feature.

For example, imagine you have an tiện ích inhỏ, icon.png, và need chất lượng version ofit for different locales. However, two locales, English-Canadian và French-Canadian, need touse the same version. You might assume that you need to lớn copy the same imageinlớn the resource directory for both English-Canadian and French-Canadian, but it"snot true. Instead, you can save sầu the image that"s used for both as icon_ca.png (anyname other than inhỏ.png) and putit in the mặc định res/drawable/ directory. Then create an ibé.xml tệp tin in res/drawable-en-rCA/ & res/drawable-fr-rCA/ that refers khổng lồ the icon_ca.pngresource using the element. This allows you lớn store just one version of thePNG file & two small XML files that point to it. (An example XML file is shown below.)

Drawable

To create an alias to lớn an existing drawable, use the element. For example:

Bài viết liên quan

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *