Jun
Jun

Reputation: 41

Android 2.2 - screen resolutions and sizes issue

The android version is 2.2. And the apps will not support drawable-xhdpi with drawable-xlarge folder. However, i have met many issue when I am processing different screen size from different mobile.

The first problem is that I want to know what is the situation that android will load correct image from drawable-ldpi, drawable-mdpi, drawable-hdpi folder? There are one image in each folder (drawable-ldpi, drawable-mdpi, drawable-hdpi).

(1) 240px x 150px for drawable-ldpi
(2) 320px x 200px for drawable-mdpi
(3) 480px x 300px for drawable-hdpi

But why i cannot see correct image if the output device width screen is 480px? The output device only shown 320px width image. Not the 480px image. The issue seems that what the thing i have missing?

Then, i renamed all drawable folder to drawable-small, drawable-normal, drawable-large. It is working that drawable-large can display 480px width image. Will it be good if i do this way?

The second issue is that some samsung device have got different screen resolutions, i would like to know how to support these screen resolution as I want to make 800px width screen displays 800px width image, 900px width screen displays 900px width image? Any method can do different screen resolution? Many people said the folder drawable-xhdpi can solve issue that image can be auto-scaling. I cannot see any image can be auto-scaling. Maybe i have missing some steps.

Kindly advise.

Thanks a lot.

Upvotes: 0

Views: 3272

Answers (1)

Janpan
Janpan

Reputation: 2284

I will try to give you better insight into this.

Screens can be divided into more or less 4 different categories:

  1. Low-density
  2. medium-density (Baseline)
  3. high-density
  4. extra-high-density

You also get xxhdpi these days...

  • low-density = ldpi (120dpi)

  • medium-density = mdpi (160dpi)

  • high-density = hdpi (240dpi)

  • extra-high-density = xhdpi (320dpi)

Another good example comes from the android developer pages:

http://developer.android.com/images/screens_support/screens-ranges.png

You can find a list of devices and their pixel densities here:

  • h ttp://en.wikipedia.org/wiki/List_of_displays_by_pixel_density

  • h ttp://checkscreensize.appspot.com/listdevice.jsp

You will always be designing apps with multiple layouts/drawables to support different devices. Not just Samsung devices, but most brands have different devices with different pixel densities and resolutions.

In short, by providing multiple resources, android will choose the correct one to best fit the current device and if it does not find one in a certain layout or drawable folder, it will simply use the next best layout/resource with that name.

Note, this is to avoid stretching and incorrect scaling of drawables and layouts.

How to support multiple layouts ?

in your manifest file.

<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
  • Provide different layouts or drawables for different screen sizes.

Now, there are multiple ways of doing this and some ways are dependent on the sdk level.

  • Pre Android 3.2 / API 13 , use layout-small/normal/large/xlarge.
  • After Android 3.2 / API 13 , use layout-hdpi, or layout-sw600dp etc.

Here is the official table of qualifiers you can use, by placing a dash between them:

Generally, I think that you will only design for landscape mode with tablets, therefore, you could consider using only these and:

  • layout-ldpi
  • layout-mdpi
  • layout-hdpi
  • layout-xhdpi
  • layout-large
  • layout-large-land
  • layout-xlarge
  • layout-xlarge-land

and for your drawables:

  • drawable-ldpi
  • drawable-mdpi
  • drawable-hdpi
  • drawable-xhdpi

Further, by default, I currently choose to design for 6 different devices that overall fits best in the profiles ldpi, mdpi, hdpi, xhdpi for phones (4) and tablets (2):

  • Samsung Galaxy S3 (720x1280, xhdpi, Normal screen size)
  • Samsung Galaxy S2 (480x800, hdpi, Normal screen size)
  • Samsung Galaxy Ace Plus (320x480, mdpi, Normal screen size)
  • Samsung Galaxy Mini (240x320, ldpi, Normal screen size)
  • Samsung Galaxy Tab 10.1 (800x1280, mdpi, X-Large screen size)
  • Samsung Galaxy Tab 7.0 (600x1024, hdpi, Large screen size)

Designing for these devices ensures that the app will work great on most other devices aswell.

Hope this information helped.

Upvotes: 6

Related Questions