Android supporting all tablets - categorize drawables and layouts

后端 未结 5 575
野的像风
野的像风 2021-01-31 11:40

I have seen many thread discussing this problem in stackoverflow (like this, this and this), and I have read the documentation about supporting multiple screens, and designs. Bu

相关标签:
5条回答
  • 2021-01-31 12:17

    AFAIK there are two kinds variables for device display : pixel density and screen dimensions. Both are theoretically independent, though in market both vary together from low end to high end devices.

    Pixel density demands for different bitmap resolutions and level of detail (36X36 to 96X96 icons for example) .

    Screen dimensions demand for better use of real estate ( Multi activity layout for phones, combined fragmented layout for tablets, for example). Not as important as pixel density, but good to have, because tablet users might find a phone layout too bland, and waste of screen space.

    So:

    • To cover most pixel densities you will have to have different versions of drawables : ldpi,mdpi,hdpi and xhdpi. Prefer nine-patch drawables, these are a lot better at fitting everywhere.

    • To cover most screen sizes you will have to have different layout arrangements, and a responsive layout design for small,large and xlarge values. Also, different layouts for portrait, and landscape orientations are good to have sometimes.

    • Android lets you mix configuration combinations too. E.g. drawable-large-hdpi etc.

    • Avoid hard coded pixel co-ordinated and dimensions at all costs, use density or percentage.

    • Its Way better to have one flexible nine-patch drawable than to have different drawables for different screen sizes.

    0 讨论(0)
  • 2021-01-31 12:21

    Hello i think android drawable resolution is-

    10" - 1280 X 800

    7" - 1024 X 600

    xhdpi - 960 x 720

    hdpi - 800 X 480

    mdpi - 480 X 320

    0 讨论(0)
  • 2021-01-31 12:25

    We can also use xxhdpi for drawables like drawable-xxhdpi

    xxhdpi (480dpi, Android 4.1 or later)

    Or refer "Android Tabular Column" in the follwing link

    http://en.wikipedia.org/wiki/Smartphone

    0 讨论(0)
  • 2021-01-31 12:29

    Actually Tablets are categorized by size not by dpi, i.e 7" tab is drawable-large while your 10" tab is drawable-xlarge. And now you can again categorized by dpi like drawable-large-hdpi which means it is a Tab of 7" which having High Density.

    you can use SW smallest width concept to target that, see Application Skeleton to support multiple screen and make calculation for the same.

    Tablet Tablets are categorized into two size.

    7" (1024X(600-48(navigation bar))) = 1024 X 552 (drawable-large)
    10" (1280X(800-48(navigation bar))) = 1280 X 752 (drawable-xlarge)

    and for 2560x1600 calculate SW dp with formula

    px= Device's width
    dpi= Device's density

    formula given

    px = dp * (dpi / 160)
    

    interchange formula if you have px's value

    dp = px / (dpi / 160)
    

    so drawable-swxxxdp will do the job

    0 讨论(0)
  • 2021-01-31 12:35

    What I have come to use is:

    • one layout folder (or second one: layout-land)
    • a few values folders with dimens.xml (-hdpi, -large, -xlarge) for different sizes, fonts etc.
    • drawables: -hdpi with most images, they scale down for all the phones; -large for 7" tablets; -xlarge for 10" tablets. Or just -hdpi and -large.

    I might verify this approach, i.e. use -sw600dp and -sw720dp but for now it works.

    0 讨论(0)
提交回复
热议问题