Android 屏幕分辨率 px 和 dp
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10565976/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Screen Resolutions px and dp
提问by 43.52.4D.
For icons they are: 36x36px 48x48px 72x72px 96x96px
对于图标,它们是: 36x36px 48x48px 72x72px 96x96px
And for screen sizes they are: 426x320 470x320 640x480 960x720
对于屏幕尺寸,它们是:426x320 470x320 640x480 960x720
But I think I might have heard from the website that those screen sizes are in dp. I know that "dp" is dimmensional pixels. But my question is: When I go into Adobe Illustrator to create a background for the small screen size (426x320), should I use the unit PIXELS or do I need to convert those numbers to something else.
但我想我可能从网站上听说那些屏幕尺寸是 dp。我知道“dp”是维度像素。但我的问题是:当我进入 Adobe Illustrator 为小屏幕尺寸 (426x320) 创建背景时,我应该使用单位 PIXELS 还是需要将这些数字转换为其他数字。
回答by android developer
dp is not "dimmensional pixels" . it's "(density) independent pixels" (see hereand here) . they are based on the density of the device , not the resolution .
dp 不是“维度像素”。它是“(密度)独立像素”(参见此处和此处)。它们基于设备的密度,而不是分辨率。
for example , for application icons , it's always 48 dp , since on mdpi(160 dpi) , 48 dp== 48 pixels . therefore , on hdpi (240 dpi) , it's 48*1.5=72 pixels , on ldpi(120 dpi) it's 48*0.75=36 , and on xhdpi (320 dpi) it's 48*2=96 pixels .
例如,对于应用程序图标,它总是 48 dp,因为在 mdpi(160 dpi) 上,48 dp== 48 像素。因此,在 hdpi (240 dpi) 上为 48*1.5=72 像素,在 ldpi(120 dpi) 上为 48*0.75=36 ,在 xhdpi (320 dpi) 上为 48*2=96 像素。
if you wish to have the best results of showing images, create the images based on the dpi level of your target devices. this means that for each dpi level , you need to create an image best suited for it , and put it on the correct folder in the "res" folder .
如果您希望获得最佳的图像显示效果,请根据目标设备的 dpi 级别创建图像。这意味着对于每个 dpi 级别,您需要创建最适合它的图像,并将其放在“res”文件夹中的正确文件夹中。
this could take x4 times , and you might simply prefer having a single file instead . it all depends on the result that you see. if you can't tell the difference of your image on an mdpi device and xhdpi device , you don't have to make any changes.
这可能需要 x4 次,而您可能更喜欢使用单个文件。这一切都取决于你看到的结果。如果您无法区分 mdpi 设备和 xhdpi 设备上的图像,则无需进行任何更改。
for more information on android graphical design , read this: http://developer.android.com/design/index.html
有关 android 图形设计的更多信息,请阅读:http: //developer.android.com/design/index.html