Working with Images in Android Application Development

A lot of new question, but I can not find a clear answer on the net or in the books that I have. I am developing an application for compatibility with all types of Android devices and I want to display images in my application. I understand that android automatically scales images in accordance with the resolution of the displayed screen.

My question is what am I looking for in the images that I use? For instance. I have a 2418 x 2192 @ 240dpi image. As far as I can tell, this should be perfect for a larger screen such as a tablet. If I put this in the xhdpi image folder in my project, will it be detected by other devices and scaled according to their size / resolution? Should I create 3 different versions of this image in Photoshop and put them in the appropriate tag folders?

I can’t find a good primer for this, so I don’t know what I am doing!

+4
source share
2 answers

This is the best place to start supporting multiple screen sizes:

http://developer.android.com/guide/practices/screens_support.html

Short answer: yes, you place images in different directories based on resolution, and Android will choose which image to use based on the device’s properties. You should make a smaller set of images, for example, for mdpi and hdpi. You should not "do" this, and if you just put the image in a drawable, you can reduce it, but, as a rule, this is not the best way.

+2
source

This is something that you will deal with almost the entire project, because there are simply so many Android devices. This resource helped me a lot.

If you have a resource in only one folder, Android will scale it for you. The various folders available are designed so that the developer can provide scalable images with minimal effort. For example, you might want to provide xhdpi in addition to the “standard” mdpi image, so that assets look better on high-resolution devices. The application will work fine (and have scaled images) in all resolutions, even if you provide only one image. However, if you provided xhdpi drawable, then a bit of overhead to scale everything down, and especially for icons, the results may not look very good (or even be recognizable).

I usually provide resources for mdpi and xhdpi, but if the application is often used on low-resolution devices, I also provide ldpi. If possible, I include all four.

Note. The image shown is too large to be included in the user interface resources and is probably best placed in assets and loaded on demand. Even on xhdpi devices it will need to be reduced.

+2
source

Source: https://habr.com/ru/post/1441312/


All Articles