I'm trying to import a 600x600 PNG I made into my Android project so that I can use it as a full-sized image in an Activity. Dragging and dropping it onto my /res folder just puts it in that folder, which of course generates an "invalid resource directory name" error. I can drop it into any of the /res/drawable folders and that works fine, except then it's only in that one folder. Surely, there's an inbuilt tool which can take my image and scale it appropriately for each /res/drawable folder.
-
This would require knowing what dpi resolution the original image was intended for, and would be something implemented as part of the Android Tools for Eclipse, rather than Eclipse itself. There are no inbuilt tools. – biddulph.r Mar 30 '13 at 00:26
-
"implemented as part of the Android Tools for Eclipse, rather than Eclipse itself" Yeah, that's what I meant when I said 'inbuilt'. My bad, I worded it wrong. – flyingsandwich Mar 30 '13 at 00:37
4 Answers
AFAIK there isn't.
What you can do though, is use the drawable-xhdpi
folder only. Android will automatically scale down for lower dpi.
The only exception is the launcher icon. You will have to provide all sizes (don't forget xxhdpi for tablets!).
You can find the needed sizes in the Icon Design Guidelines.
It is important to note that the ADT plugin does have tools for generating some icons sets, such as Launcher icons, Actionbar icons and Notification icons.
These tools can be accessed by opening the New wizard (Ctrl + N) and double-clicking Android Icon Set in the Android category.

- 25,285
- 12
- 54
- 61
-
Oh, fantastic. Thankfully there's a wizard for launcher icons and stuff like that. – flyingsandwich Mar 30 '13 at 00:54
-
"Android will automatically scale down for lower dpi." > Is this done at compilation time? Otherwise, at runtime, this will lead to a poor user experience for devices with low CPU and/or low memory. – Mick F Jul 08 '13 at 16:30
-
This is done at runtime. I haven't had any problems using this method myself, but you could be right about low-end devices. The only problem I know of is that the scaling process might create bitmap artifacts. You can read more about this [here](http://developer.android.com/guide/practices/screens_support.html#support). There is also a [discussion](http://stackoverflow.com/questions/5998865/only-use-xhdpi-drawables-in-android-app) about this subject on SO. – Benito Bertoli Jul 08 '13 at 20:02
-
Please note that xhdpi was introduced with API 9 (Android 2.3) and older devices (if you target them) won't see these images at all. – BladeCoder Jul 07 '14 at 14:56
-
Dirty Henry is right, low-end devices or just old devices (2.3) can run into the famouus out of memory exception by using this technique. Than again, we can almost get rid of those devices anyway since nothing will really run smootly anymore on those devices :). BTW if you want the opposite, you can use the drawable-nodpi and Android won't rescale the images then – Jordy Nov 04 '14 at 16:53
-
Since the image will be scaled down for lower densities, it is very unlikely to get an out of memory error, unless of course the image is very large to begin with, which will probably cause an error even on larger densities. Using the nodpi folder, on the other hand, might be problematic, because the image won't be scaled down. So it will need the same amount of memory on all devices, including lower-end. – Benito Bertoli Nov 04 '14 at 22:53
there's an inbuilt tool which can take my image and scale it appropriately for each /res/drawable folder.
For the scaling part, check out the Icon Generators Tools @ Android Asset Studio. There are tools for generating Launcher icons, Tab icons, Action bar icons and (in your case) Generic icons.

- 16,292
- 20
- 87
- 132
Luckily this changed - you are now able to autogenerate different densities - take a look at: https://code.google.com/p/android-drawable-converter/

- 20,366
- 24
- 120
- 181
If you put your drawable resources in /res/drawable, that resource will be used for all devices.
However, it probably won't do exactly what you want. I would recommend scaling the assets yourself. If that isn't a viable option, then you are stuck with letting Android do the scaling for you.

- 66,602
- 10
- 133
- 120
-
My project doesn't have a single /res/drawable folder, it has five drawable folder for the different DPI categories. If I manually add a singular drawable folder, will that work? EDIT: Don't know why I didn't just try that - I am truly lazy. Okay, it seems to have worked. At least, I don't have any errors yet. – flyingsandwich Mar 30 '13 at 00:37