amir_70
amir_70

Reputation: 930

is it important to name drawable-hdpi for image in hdpi resolution?

I did some google search and look at documentation but i didn't find my answer. Suppose i have an image and two version of it. One for hdpi devices and the other for ldpi devices . Is it important to have two folder with exact name drawable-hdpi and drawable-ldpi ? If yes is this the pattern to use drawable-amountofpixel ? If no how android knows which folder to use when app is running on a hdpi device ?

Upvotes: 0

Views: 158

Answers (2)

CommonsWare
CommonsWare

Reputation: 1006789

Is it important to have two folder with exact name drawable-hdpi and drawable-ldpi ?

Yes. More accurately, it is important to have two directories that start with drawable and contain -hdpi and -ldpi as appropriate. It is possible to have more complex scenarios (e.g., drawable-sw800-hdpi).

If yes is this the pattern to use drawable-amountofpixel ?

The pattern is to use the density qualifiers that are covered in the documentation. See:

Upvotes: 1

Rahul
Rahul

Reputation: 10625

If App is running on hdpi phone, it will look for the assets and on a same time it will give preference to those icons which are present on drawable-hdpi or drawable-ldpi depending on the screen resolution of phone.

For example let us suppose you have image in drawable-ldpi folder, open your App in hdpi or xhdpi phone. You will find that icon is looking small on those screens but on a same way if you will show drawable-hdpi icon in ldpi phone you will observe that icon is looking large.

Check this answer to understand more about pixels and how they work on muti screens.

https://stackoverflow.com/a/45244453/1380032

Upvotes: 1

Related Questions