Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xlarge vs sw720dp screen size confusion

Tags:

android

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

The old style size quantifiers are "deprecated":

A set of four generalized sizes: small, normal, large, and xlarge Note: Beginning with Android 3.2 (API level 13), these size groups are deprecated in favor of a new technique for managing screen sizes based on the available screen width. If you're developing for Android 3.2 and greater, see Declaring Tablet Layouts for Android 3.2 for more information.

I was hoping that devices with 3.2+ would still use resources declared in drawable-large-mdpi, or layout-xlarge, but this doesn't seem to be the case.

I have a test project that contains a layout file for each of these sizes:

  • layout-sw600dp
  • layout-720dp
  • layout-xlarge
  • layout

On a 10" Motorola XOOM running Android 4.0.x, the device picks the layout in the layout-720dp folder. If that folder doesn't exist, it picks the layout in the layout-sw600dp folder! Why doesn't it pick the layout in layout-xlarge?

Even more strange, is I have drawables in these folders:

  • drawable-sw600dp-mdpi
  • drawable-xlarge-mdpi

The 10" Motorola XOOM from above, picks the image from drawable-sw600dp-mdpi. Why doesn't it pick the drawable in drawable-xlarge-mdpi?

Should we not expect the xlarge quantifier to work at all above Android 3.2?

Does this mean I have to duplicate all assets in the drawable-xlarge-mdpi folder, into the drawable-sw720dp-mdpi folder? (To support Android 3.0, 3.1 AND 3.2+?)

Hopefully I am just missing something simple here. Please advise.

like image 448
NPike Avatar asked Jul 20 '12 15:07

NPike


People also ask

What does the W mean on a widescreen screen?

When the overall aspect ratio increased from 4:3 to 16:9, the new widescreen screens in the US were marked with the letter W.

What does the screen size comparison chart show?

This screen size comparison chart shows the screen resolution and the pixel density of each device as well as other metrics like the CSS width. Finally, a simple solution to US sales tax in WooCommerce. Get all 50 US state’s sales tax rates in one CSV file.

How to target screens with minimum width given in DP?

The Smallest-width qualifier allows to target screens that have a certain minimum width given in dp. Lets take three layout folders named res/layout, res/layout-sw600dp and res/layout-sw720dp. We also have some layouts named main.xml, details.xml and item.xml in base layout folder.

What are Android screen sizes and screen densities?

A quick note today on Android screen sizes and screen densities. According to the Supporting Multiple Screens document on the Android website, Android screens are broken down into a set of four generalized sizes: small, normal, large, and xlarge.


1 Answers

From my understanding, for Android 3.2+, if you have at least one folder that uses the new size quantifiers then it assumes that you are using these new size quantifiers everywhere. So this is the reason why it ignores layout-xlarge or any other folder that uses the old quantifiers.

With regard to backward compatibility, you'll have to use in your project both types of quantifiers. The old ones will be used for API < 3.2 and the new ones for API >= 3.2. To avoid duplication, for the layouts you can use aliases. However, for drawables, I don't know of any solution to avoid duplication.

like image 52
Catalin Morosan Avatar answered Oct 02 '22 16:10

Catalin Morosan