Search code examples
androidandroid-layoutdpi

Create layout set that is covering most of the Android devices


I'm working on an application that the client wants to has the same looks on all supporting devices. This application will support Android 4.0.3 or above for the following devices.

  • mid-to-high end phone portrait (including Phablet)
  • 7" tablet portrait (same layout with phone)
  • 10" tablet landscape

If I create a layout like this

  • layout (mid-end phone, high-end phone, phablet and 7" tablet)
  • layout-sw720dp-land (for 10" tablet)

and define all the ui dimensions and drawable in

  • values-sw320dp, drawable-sw320dp (most of the mid end phone)
  • values-sw360dp, drawable-sw360dp (most of the high-end phone)
  • values-sw480dp, drawable-sw480dp (some phablet phone like Samsung Galaxy Mega)
  • values-sw600dp, drawable-sw600dp (7" tablet)
  • values-sw720dp, drawable-sw720dp (10" tablet)

My questions are

  1. will that covering all the devices I mentioned?
  2. values is equal to values-sw320dp, is that correct?
  3. device like Samsung Galaxy Tab 2 7" has an onscreen control so its dp is actually lower than 600dp. Then, in my case, it will load values and drawables from sw480dp, is it correct?

Thank you.


Solution

  • Will that covering all the devices I mentioned?

    From the list given, it seems that you should already cover all the cases. Please take note that there is no hard line whether a device is a phone or tablet given its size/resolution. Here is a general guideline by Google:

    To help you target some of your designs for different types of devices, here are some numbers for typical screen widths:

    • 320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
    • 480dp: a tweener tablet like the Streak (480x800 mdpi).
    • 600dp: a 7” tablet (600x1024 mdpi).
    • 720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).

    Values is equal to values-sw320dp, is that correct?

    The device will use any resources that is the most suitable based on its qualifier. If a device has smallest width between 320dp-359dp, it will use both resources from /values-sw320dp and /drawables-sw320dp. If it's between 360dp-479dp, it will use the next one. Meanwhile, a general/default resource should be put in /values and /drawable (without qualifier).


    Device like Samsung Galaxy Tab 2 7" has an onscreen control so its dp is actually lower than 600dp. Then, in my case, it will load values and drawables from sw480dp, is it correct?

    Again, from Android developer's guide:

    The smallestWidth of a device takes into account screen decorations and system UI. For example, if the device has some persistent UI elements on the screen that account for space along the axis of the smallestWidth, the system declares the smallestWidth to be smaller than the actual screen size, because those are screen pixels not available for your UI.

    According to this definition, system UI such as soft-menu won't be included in the calculation. You're correct about the concept.


    After all, you should test all your layouts with real devices/emulator and see the final result. By using emulator, you can specify the configuration easily for testing.