Reputation: 10759
So I am new to Android development. In iOS you can make a reference to an image "thing.png" and even though you have the following filenames iOS grabs the correct image per the screen res.
[email protected]
thing.png
[email protected]
I have icons in Android, from the material design download on GitHub, that are names as follows.
ic_cancel_18dp.png
ic_cancel_32dp.png
ic_cancel_48dp.png
My question is in Android can I just reference them like @drawable/ic_cancel.png and Android will grab the correct one per the screen res?
Upvotes: 0
Views: 51
Reputation: 7929
You only need to put your.png
files in the relevant directory, and use the same name.
For example:
Rename all your files to ic_cancel.png
.
In res/drawable-mdpi
, put your old ic_cancel_18dp.png
In res/drawable-hdpi
, put your old ic_cancel_32dp.png
In res/drawable-xhdpi
, put your old ic_cancel_48dp.png
In your code, just use ic_cancel.png
as reference to your image.
For more info, take a look at Using configuration qualifiers.
Upvotes: 1