Difficulty to understand how to support multiple screen

喜你入骨 提交于 2019-12-03 13:59:15

问题


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 got this. I am working with screen sizes first time so please help me.

xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp

And in case of xhdpi they suggest 320 density. I am confused so I have following questions.

  1. Like if I want to create Background image for xlarge screen then 960dp x 720dp means I have to create image with width 720 pixels and height 960 pixels and resolution 320 in portrait mode?

  2. And if I want to create Background image for large screen then 640dp x 480dpp means I have to create image with width 480 pixels and height 640 pixels and resolution more than 200 in portrait mode?

  3. The sizes above is for landscape mode i.e 960dp for width and 720dp for height ?


回答1:


In android-

px = dp * (dpi / 160)
  1. So in your first question 960dp x 720dp at 320dpi means 1920px x 1440px for xlarge screen in landscape mode using above formula.

  2. 640dp x 480dp at 240dpi means 960px x 720px for large screen in landscape mode.

To learn more about check this.




回答2:


From Android: Supporting Multiple Screens

px = dp * (dpi / 160)


So for your example:

Your image dimensions are 960dp x 720dp and your dpi is 320 (which you can see falls under XHDPI).

Height = 960dp * (320 / 160) = 1920px

Width = 720dp * (320 / 160) = 1440px

Height and width are arbitrary depending on the orientation of the phone




回答3:


Refer this for Conversion of dp into px for each dpi (Android)




回答4:


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



来源:https://stackoverflow.com/questions/21144388/difficulty-to-understand-how-to-support-multiple-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!