Difficulty to understand how to support multiple screen

前端 未结 4 590
Happy的楠姐
Happy的楠姐 2021-02-06 18:06

I have seen so many questions on StackOverFlow how to support multiple screens. But most of the answers provide this link and this. And in the first one link I have

4条回答
  •  暖寄归人
    2021-02-06 18:48

    dp means density independent pixel. When you say for example 300dp means 300 pixels on a medium density (160dpi) screen. So if you want to translate dp on real resolution you have to multiply the dp for the density scale factor: es 300dp are

    1. 300 px on a mdpi screen
    2. 450 px on a hdpi screen
    3. 600 px on a xhdpi screen

    so if you specify resources you should remember to use both size and density modifiers a background for a 480x800 px medium screen phone woul be picked from normal-hdpi folder an so on

提交回复
热议问题