1

In the xhdpi density range

There are multiple resolution devices

like Nexus 7 with 1200 X 1920 pixel resolution which comes under xhdpi and Nexus 9 with 2048 X 1536 pixel resolution which also comes under xhdpi

samsung galexy note pro has 2560 x 1600 pixel resolution which also comes under xhdpi density

So if i design with 1200 X 1920 and place assets values in dimens-xhdpi then it wont fit for 2048 X 1920 or 2560 x 1600 resolution devices how can we make it compatible for all

I didn't really understand how to make it compatible Reading the developers documentation, if somebody could explain that would be so helpful

George Thomas
  • 4,566
  • 5
  • 30
  • 65

1 Answers1

1

Screen density and screen size are two different things. On Android you have to primarily design for densities not for screen sizes. Screen sizes are supported only in a limited fashion.

Basically, you shouldn't assume set of specific widths and heights of the screen and the programmer shouldn't hardcode any pixel values in code or resources. Android runs on a huge variety of devices so it's impossible to target specific sizes.

Designers for Android typically design some standard screen size. But they know it won't look exactly like it on most of the phones. They design it so it can stretch and/or scroll. They count from start that when the screen is smaller it will e.g. scroll and when the screen is bigger there will be bigger spaces in between the views.

To further work around screen size differences, Android offers handling via ranges of screen sizes. You can either use old screen size resource qualifiers (small, normal, large, xlarge) or newer sw<N>dp, w<N>dp, h<N>dp. You can combine those qualifiers with the density qualifiers (e.g. -large-xhdpi or -sw640dp-xhdpi). This is the way phones and tables are supported in one app.

You can find more info about resource qualifiers in the documentation here and here.

Tomik
  • 23,857
  • 8
  • 121
  • 100
  • one more doubt. can we also add drawable with these qualifiers, for example what if i need different assets for 1536 x 2048 (768dp width) and 1200 x 1920 (600dp) which both comes under the xhdpi density can i place different assets like drawable-w600dp and drawable-w768dp and corresponding values like values-w600dp and values-w768dp – George Thomas Sep 21 '16 at 04:43
  • 1
    Yes, you can! In your case for xhdpi you could use resource folders e.g. `drawable-w600dp-xhdpi`, `drawable-w768dp-xhdpi` or even `drawable-sw600dp-h720dp-xhdpi`. The resource qualifiers can be combined. – Tomik Sep 21 '16 at 08:14
  • Thanks a lot! i will try to create resources and give a try :) – George Thomas Sep 21 '16 at 08:53
  • 1
    This is such a big confusion in Android development. I'm also worried about the same question. Need some more specific explanation. Can you? @Tomik@GeorgeThomas – Maulik Dodia May 27 '17 at 08:48