Putting screen densities into the correct bucket

前端 未结 6 2222
滥情空心
滥情空心 2020-12-01 01:39

A set of six generalized densities:

ldpi (low) ~120dpi
mdpi (medium) ~160dpi
hdpi (high) ~240dpi
xhdpi (extra-high) ~320dpi
xxhdpi (extra-extra-high) ~480dpi         


        
6条回答
  •  旧时难觅i
    2020-12-01 02:16

    you have to handle the resources regarding the screen width in dp not dpi(dot per inch)

    for example nexus 5 1920 X 1080 480 dpi it uses xxhdpi and nexus 6p 2560 X 1440 560 dpi it uses xxhdpi too not xxxhdpi !!

    to handle it use the smalest width resource "drawable-swXXXdp"


    width in dp = width in pixle / (dpi/160) dp= 1440/(560/160) =~ 411

    create drawable-sw411dp 
    

    Reference

提交回复
热议问题