mayur bhagat
mayur bhagat

Reputation: 209

What is best way to create drawable asset?

If I put my application resources in drawable-xdpi then it is automatically down converted for hdpi, mdpi and ldpi by ration 0.75, 0.05 and so on.

Why we need to create extra resource if one type is enough only?

I believe it is enough if I create for xhdpi and let Android down scales automatically. I have gone through this question What is the best way to create drawables for different dpi but no one has given answer that yes you can go this way.

Suppose I kept my images in xhdpi and when app opens in hdpi it will reduce size to 0.75, when it opens in mdpi it reduces size to 0.5.

So what is best way to create draw able asset? Please suggest perfect way with valid reason.

If not needed why we are creating so many resources instead for one only like xdpi?

Upvotes: 4

Views: 283

Answers (2)

Henry
Henry

Reputation: 43728

There are two reasons to provide more than one image:

  1. it is more efficient to load an image that is already the correct size.
  2. The automatic downscaling may produce artifacts, which can be disturbing especially for small images. So if you want a pixel perfect image it is better to provide one in the correct size.

If none of them is a problem for you, it is also fine to go just with one image.

Upvotes: 2

Danny
Danny

Reputation: 1050

If u want to display same image with different resolutions in devices

xhdpi image then place it drawable-xhdpi
hdpi image then place it in drawable-hdpi** 

or to maintain a drawable folder place all the images what you want to display it will display with same size in all devices irrespective of the resolution.

Upvotes: 2

Related Questions