如何在android中处理图像特别是背景图像

时间:2017-06-16 06:45:03

标签: android image user-interface

我想知道如何处理android中的图像。我如何能够使用正确的尺寸放置图像。图像的分辨率是多少?

1 个答案:

答案 0 :(得分:2)

请阅读有关屏幕尺寸的Groovy is the New Black

从基本图像尺寸来看,DPI的可绘制尺寸缩放比例为3:4:6:8:12:16。

LDPI - 0.75x
MDPI - Original size // means 1.0x here 
HDPI - 1.5x
XHDPI - 2.0x
XXHDPI - 3x
XXXHDPI - 4.0x

例如,MDPI上的100x100px图像与XHDPI屏幕上的200x200px大小相同。

您可以在此处查看不同分辨率的不同大小:

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
Generalised Dpi values for screens:

ldpi Resources for low-density (ldpi) screens (~120dpi)
mdpi Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
hdpi Resources for high-density (hdpi) screens (~240dpi).
xhdpi Resources for extra high-density (xhdpi) screens (~320dpi).
Therefore generalised size of your resources (assuming they are full screen):

ldpi
Vertical = 426 * 120 / 160 = 319.5px
Horizontal = 320 * 120 / 160 = 240px
mdpi
Vertical = 470 * 160 / 160 = 470px
Horizontal = 320 * 160 / 160 = 320px
hdpi
Vertical = 640 * 240 / 160 = 960px
Horizontal = 480 * 240 / 160 = 720px
xhdpi
Vertical = 960 * 320 / 160 = 1920px
Horizontal = 720 * 320 / 160 = 1440px

px = dp*dpi/160