Can Eclipse automatically generate different DPI i

2019-05-04 19:50发布

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.

4条回答
甜甜的少女心
2楼-- · 2019-05-04 20:09

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.

查看更多
女痞
3楼-- · 2019-05-04 20:15

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.

查看更多
爷、活的狠高调
4楼-- · 2019-05-04 20:29

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.

查看更多
乱世女痞
5楼-- · 2019-05-04 20:32

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

查看更多
登录 后发表回答