Best practices to use when targeting multiple screen resolutions on Android

前端 未结 4 908
滥情空心
滥情空心 2021-02-11 03:32

When designing an UI, we need to target many android mutations and various screen resolutions.

  • How to differentiate layout for 480 * 800 and 480 * 854 screen resolu
4条回答
  •  心在旅途
    2021-02-11 03:58

    These are some suggestions, in random order:

    • Avoid AbsoluteLayout, I know that it is deprecated, but you can still use it; forget it and use LinearLayout and RelativeLayout instead
    • Use 9-patch to create buttons and backgrounds, so that they will appear the same for each resolution
    • Use DisplayMetrics() to get informations about the screen, to show different things in different screens (i.e. to show AdMob "Banner" in smartphones and AdMob "Leaderboard" in tablets)
    • Create WVGA layout first (this is only a personal opinion, but I've found it a nice way of working): as far as I know the most smartphones are WVGA or at least HVGA (QVGA is not so frequent), so creating a perfect WVGA layout will make you able to satisfy lots of phones, than you can create a different layout for lpdi-screen and tablets (that are a market-share minority too, at the moment)

    In conclusion I recommend you to create a layout for phones and on for tablets, that can adjust itself to screen resolution: this will fit the most devices; for borderline devices (i.e. 7" tablets or 5.3" phone) I'd work with different drawables/different XML layouts.

提交回复
热议问题