Do I need 14 different layouts to support all Android devices?

后端 未结 4 486
别跟我提以往
别跟我提以往 2020-11-28 01:43

I\'m really feeling confused. From the docs at developer.android.com, it seems in order to keep my images scaled correctly (aspect ratio too) across all current Android dev

4条回答
  •  难免孤独
    2020-11-28 02:17

    According to Android Dev Protip from Roman Nurik about screen size qualifiers:

    If you have custom layouts for larger screen devices such as tablets, now's the time to stop using the -large or -xlarge resource qualifier and switch to using -swXXdp or -wXXdp qualifiers. The latter were introduced in API level 13, which basically all tablets now have support for according to the latest platform version charts1.

    means that for basically all cases where -large would have any effect, -swXXdp can be used instead to provide more granularity.

    So which actual sw or w qualifiers should you use? Here's a quick just-give-me-something starting point:

    7" tablets: Instead of layout-large, use layout-sw600dp.

    Example: Nexus 7 = 960×600 dp; the smaller of the two dimensions is 600.

    10" tablets: Instead of layout-xlarge, use layout-sw720dp.

    Example: Nexus 10 = 1280×800 dp; the smaller of the two dimensions is 800. Some 10" tablets are a bit more narrow so 720 is a commonly used switching point.

    There's more to it than just that (you really want to choose switching points based on your content's minimum requirements, not on device form factor), but that's a #Protip for another day (::cough:: +Nick Butcher ::cough::).

提交回复
热议问题