How do I prepare images for all the Android resolutions?

删除回忆录丶 提交于 2019-11-29 20:41:50

i got this off of this site a while back, it still comes in handy

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
BigPun86

In Android Studio just go to File -> New -> Image Asset and create your images right out of the IDE.

On Android we usually handle image sizes in units of "dp" or "dip" which stands for device independent pixel. 1 dip = 1 pixel, on a mdpi screen. There are loads of devices out there with different screen densities, not just normal and retina, so there are multiple DPI buckets a device's screen may fall into:

  • ldpi (low dpi): around 120 dpi
  • mdpi (medium dpi): around 160 dpi
  • hdpi (high dpi): around 240 dpi
  • xhdpi (xtra high dpi): around 320 dpi

Note that these are buckets, so a device with a 170 dpi screen will count as an mdpi device.

Let's say that you have a vector based image in PS and you need to create an image resource for Android and you'd like to support all these screen densities. Let's say that image needs to be 100x100 dip large. So you create a 100x100 pixel version for mdpi, a 150x150 pixel version for hdpi, 200x200 for xhdpi, and 75x75 for ldpi. You can think of "mdpi - xhdpi" on Android as "normal - retina" on iOS.

As for the larges image size that you can use, I really can't say. There's no hard limit as far as I know, but the device obviously won't be able to load a 20000x20000 bitmap into memory without downsampling because of heap limits.

There is an online tool for that Android Asset Studio And also there is File|New|Android Icon Set in Eclipse

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