desidigitalnomad
desidigitalnomad

Reputation: 1443

how android device identifies which layout to use

In my android app, I have set the layout resources for both large and x-large screens, viz: layout-large and layout-xlarge. When I open run it in an device emulator with "large" screen, it gets the layout from the "layout-large" folder, which seems to be correct. But when I use a device with x-large screen size, it still uses the "layout-large" resources.

The x-large device I used is a 10", 1280x800, 240dp emulator. Any idea?

I've included the following in the manifest:

<supports-screens 
android:anyDensity="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:resizeable="true" />

Upvotes: 0

Views: 152

Answers (3)

Roll no1
Roll no1

Reputation: 1393

As per Android Documentation for the runtime rendering of layout

At runtime, the system ensures the best possible display on the current screen with the following procedure for any given resource:

The system uses the appropriate alternative resource

Based on the size and density of the current screen, the system uses any size- and density-specific resource provided in your application. For example, if the device has a high-density screen and the application requests a drawable resource, the system looks for a drawable resource directory that best matches the device configuration. Depending on the other alternative resources available, a resource directory with the hdpi qualifier (such as drawable-hdpi/) might be the best match, so the system uses the drawable resource from this directory.
If no matching resource is available, the system uses the default resource and scales it up or down as needed to match the current screen size and density

The "default" resources are those that are not tagged with a configuration qualifier. For example, the resources in drawable/ are the default drawable resources. The system assumes that default resources are designed for the baseline screen size and density, which is a normal screen size and a medium density. As such, the system scales default density resources up for high-density screens and down for low-density screens, as appropriate.

However, when the system is looking for a density-specific resource and does not find it in the density-specific directory, it won't always use the default resources. The system may instead use one of the other density-specific resources in order to provide better results when scaling. For example, when looking for a low-density resource and it is not available, the system prefers to scale-down the high-density version of the resource, because the system can easily scale a high-density resource down to low-density by a factor of 0.5, with fewer artifacts, compared to scaling a medium-density resource by a factor of 0.75.

Upvotes: 0

sunil
sunil

Reputation: 6614

below link will help you to understand about how android picks up layout files on various devices

http://developer.android.com/guide/practices/screens_support.html

Upvotes: 2

AMerle
AMerle

Reputation: 4354

Are you sure the folder name is layout-xlarge and not layout-x-large ? DOC

Upvotes: 1

Related Questions