¡GoConqr estrena diseño! Cuéntanos qué te parece.

Apuntes

Supporting Different Devices

PIKANSHU KUMAR Computer Studies GRE Inglés 1 página

Contenido del apunte (1)

Página 1

To add support for more locales, create additional directories inside res/. Each directory's name should adhere to the following format:<resource type>-b+<language code>[+<country code>]

For example, values-b+es/ contains string resources for locales with the language code es. Similarly, mipmap-b+es+ES/ contains icons for locales with the es language code and the ES country code.

Caution: Never save resource files directly inside the res/ directory—it will cause a compiler error.

Resource directories supported inside project res/ directory : animator/, anim/,color/, drawables/, mipmap/, layout/, menu/, values/, raw/, xml/.

Files in assets/ are not given a resource ID, so you can read them only using AssetManager.

The resources that you save in the subdirectories defined above are your "default" resources.

For instance, you should include alternative drawable resources for different screen densities and alternative string resources for different languages.

At runtime, Android detects the current device configuration and loads the appropriate resources for your application.

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

Create a new directory in res/ named in the form <resources_name>-<config_qualifier>.

<resources_name> is the directory name of the corresponding default resources (defined in table 1).

<qualifier> is a name that specifies an individual configuration for which these resources are to be used (defined in table 2).

You can append more than one <qualifier>. Separate each one with a dash.

Caution: When appending multiple qualifiers, you must place them in the same order in which they are listed in table 2. If the qualifiers are ordered wrong, the resources are ignored.

Android selects the version of each resource that best matches the current device, by comparing the device configuration information with the qualifiers in the resource directory name.

if you use multiple qualifiers for a resource directory, you must add them to the directory name in the order they are listed in the table.

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 qualifer to create the layout resources, res/layout-sw600dp/. The system will use 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 smallestWidth is a fixed screen size characteristic of the device; the device's smallestWidth does not change when the screen's orientation changes.

Also see the android:requiresSmallestWidthDp attribute, which declares the minimum smallestWidth with which your application is compatible, and the smallestScreenWidthDp configuration field, which holds the device's smallestWidth value.

Note: Using a size qualifier does not imply that the resources are only for screens of that size. If you do not provide alternative 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 notuse them and your application will crash at runtime (for example, if all layout resources are tagged with the xlarge qualifier, but the device is a normal-size screen).

Table 2 :

Información

Descripción
GRE Computer Studies Apunte sobre Supporting Different Devices, creado por PIKANSHU KUMAR el 01/03/2017.
Creado por
PIKANSHU KUMAR
Visitas
2
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?