2

I have searched a lot on this topic on internet and found some useful links but still not able to design UI that supports all device sizes and resolutions. I have read details about this topic from developers site Supporting Multiple Screens and this blog about smallest width technique. Currently i have followed this approach In which i have created a single layout folder and setting dimensions for each screen density in different folders. Currently my res folder looks like this

res

I have created a single layout folder and defined its dimensions in default values folder for normal screen size (that is Nexus S 4.0inch 480x800 hdpi), then i have copied that dimen file in values-sw600dp folder and adjusted dimensions for tablet that is correctly picking up for 7inch tablet. But now i am trying to design for other handsets/devices like Galaxy Nexus 4.7inch 720x1280 xhdpi or other large size handsets like galaxy s3,s4 etc but have no clue how to do it. If i put dimen file into values-sw320dp-xhdpi folder to adjust it for Galaxy Nexus 4.7inch 720x1280 it also changes for normal(Nexus S 4.0inch 480x800 hdpi) screen. So i am really confused about these design qualifiers. Can anyone describe an exact way or standard method/layout hierarchy to support all screen sizes?

Community
  • 1
  • 1
Nouman Bhatti
  • 1,777
  • 4
  • 28
  • 55
  • make sure you don't get confused with pixels and dp's. with a Galaxy Nexus 4.7 720x1280 xhdpi (so 2x), your smallest width is still less than 480dp – dumazy May 04 '15 at 07:13
  • so it means for both Galaxy Nexus 4.7 720x1280 xhdpi and Nexus S 4.0inch 480x800 hdpi same folder would be used that is values-sw480dp? – Nouman Bhatti May 04 '15 at 07:23

2 Answers2

1

You might be confused with pixels and density-independent pixels (dp or dip).

Galaxy Nexus 720x1280 pixels xhdpi (2x)means 360x640 in dp values, so smallest width (sw) is 360. Nexus S 4.0inch 480x800 hdpi (1.5x)has smallest width of 320

So both of these will get there values from values-sw320

dumazy
  • 13,857
  • 12
  • 66
  • 113
  • ok now i have got your point, but is my approach of creating a single layout folder and have multiple values folder to support multiple screens is correct? – Nouman Bhatti May 04 '15 at 07:35
  • It depends on what you do. If your layout looks the same on all devices, just with other dimensions, it's correct. If you have a different layout on large tablets than you have on phones, for example multiple fragments on tablet and only one fragment on phone, then you should create different layout files – dumazy May 04 '15 at 08:14
0

Create different layout folders for different screen sizes such as layout-large,layout-small, layout-xlarge,layout-xxlarge etc. But I don't know which layout you have used in xml files. Always try to use LinearLayout and RelativeLayout. Don't use pixels in xml files.

In Manifest add support-screens

<supports-screens android:resizeable=["true"| "false"]
              android:smallScreens=["true" | "false"]
              android:normalScreens=["true" | "false"]
              android:largeScreens=["true" | "false"]
              android:xlargeScreens=["true" | "false"]
              android:anyDensity=["true" | "false"]
              android:requiresSmallestWidthDp="integer"
              android:compatibleWidthLimitDp="integer"
              android:largestWidthLimitDp="integer"/>
mInE.....
  • 143
  • 11