How can I create Android images with good resolution?

眉间皱痕 提交于 2019-12-11 17:59:32

问题


I'm creating an Android application. The main activity layout will have a background image that will wrap with the whole screen. What resolution should I use to create the background image? What about DPI? I need it to be compatible with all devices (for example the HTC Sensation screen's resolution is 540 × 960 pixels).


回答1:


The best way for you is to start reading this article, it contains the best practices for supporting multiple screen sizes and densities.

EDIT:

I use the following directories to store the drawables for maximum size and density optimization:

Small screens support

  • drawable-small-hdpi
  • drawable-small-ldpi

Normal screen support

  • drawable-normal-mdpi
  • drawable-normal-hdpi

Large screens support

  • drawable-large-mdpi

Tablet screen support

  • drawable-xlarge-mdpi

Of course not every time this solution is the best, aqs's solution is more common used. You can follow this site to track which screen sizes and density's are most used and decide which of the screens worth support for your application. And of course you can read about the Providing Alternative Resources to understand better what are your options.




回答2:


You should read Supporting multiple screens. You must define dpi on your emulator. 240 is hdpi, 160 is mdpi and below that are usually ldpi.

Extract from Android Developer Guide link above:

320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).  
480dp: a tweener tablet like the Streak (480x800 mdpi).  
600dp: a 7” tablet (600x1024 mdpi).  
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).



回答3:


IMHO answer of @Cata is a bit misleading because of mixing screen size and screen density for providing graphics.

I think the best practice is to distinguish this two things by providing:

  • different size images (PNGs) for different densities and
  • different layouts for different generalized screen sizes.

By doing so developer can reduce number of different images to 4 categories (ldpi, mdpi, hdpi, xhdpi) if he wants to support all currently existing densities. Of course XML layouts files for different (small, normal, large, xlarge) screen sizes are necessary if we support them but it is much easier to make/edit/correct/adjust xml files than PNGs.

A bit more details and explanation u can find in my previous answer about this topic on this link.

Hope u find this answer useful. Cheers.



来源:https://stackoverflow.com/questions/8956408/how-can-i-create-android-images-with-good-resolution

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