简体   繁体   中英

Is there a built-in method to add drawable that is not an icon using Android Studio?

I know that I can right-click on res folder, select "New > Image asset" but while it allows me to select type of added icon it assumes that I want to add an icon.

I know that I can manually generate images and move them into drawble-mdpi, drawable-hdpi, drawable-xhdpi but I assume that it is possible to automate it and supply single image that will be scaled to create lower-resolution versions.

I know about Fast ways to import drawables in Android Studio? but it was not restricted to built-in options and an accepted version is plugin that received last update in 2016 and appears to be no longer maintained - NullPointerException report received no response from maintainer .

You can use vector asset studio.You can also lookout below link:- Running Vector Asset Studio To start Vector Asset Studio:

In Android Studio, open an Android app project. In the Project window, select the Android view. Right-click the res folder and select New > Vector Asset. Some other project views and folders have this menu item as well.

Vector Asset Studio appears.

Importing an SVG or PSD file After you open Vector Asset Studio, you can import an SVG or PSD file as follows:

In Vector Asset Studio, select Local file. The file must be on a local drive. If it's located on the network, for example, you need to download it to a local drive first.

Specify an Image file by clicking … . The image appears in the Vector Drawable Preview.

If the SVG or PSD file contains unsupported features, an error appears at the bottom of Vector Asset Studio

https://developer.android.com/studio/write/vector-asset-studio.html#running

Unfortunately after posting and creating a bounty, I found that it was already asked as Is there a way to create xxhdpi, xhdpi, hdpi, mdpi and ldpi drawables from a large scale image?

Therefore Is there a way to create xxhdpi, xhdpi, hdpi, mdpi and ldpi drawables from a large scale image? has some useful options quoted below:

Option #1: Just ship the -xxhdpi drawables and let Android downsample them for you at runtime (downside: will only work on fairly recent devices, where -xxhdpi is known).

Option #2: Automate the process within a graphics editor, per ssantos' answer.

Option #3: Script yourself a solution, using something like ImageMagick.

(answers by CommonsWare)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM