Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to choose correct image resolution for android

I have been battling with this for a couple of days. I am trying to write a small custom rating bar. With some custom images. When I check the image I have on my HTC Desire, the image looks horribly aliased. I have tried using different resolutions and different sizes and still can't figure out what resolution/how to create a good quality.

I have read the guidelines on the android site but, to no avail. I think the problem I am having is displaying lower resolution images on a higher dpi display. So the system upscales the image. But I am not sure how to fix that. Higher resolution images? Larger images?

Any advice would be great.

Alex

like image 921
Alex Avatar asked Mar 11 '11 22:03

Alex


People also ask

What is the recommended image format in Android?

Android 12 (API level 31) and higher support images that use the AV1 Image File Format (AVIF). AVIF is a container format for images and sequences of images encoded using AV1. AVIF takes advantage of the intra-frame encoded content from video compression.

How do I check image size on Android?

On android go to photos, select your photo and click the ... in the top right. Scroll to bottom of page to find image size.


1 Answers

The reason why this is a bit of a challenge to get right is the wide variety of screen-resolutions and -densities of Android devices. Fortunately the Android SDK has pretty extensive support in this department. A very good start is this section of the Android Dev Guide.

Basically you need to understand the concept of Density-independent pixels (dp) and use classes like DisplayMetrics to calculate actual screen pixels. And yes, obviously you'll need larger, higher resolution images for higher density screens.

like image 141
Josef Pfleger Avatar answered Oct 12 '22 22:10

Josef Pfleger