简体   繁体   English

是否有使用 Android Studio 添加不是图标的可绘制对象的内置方法?

[英]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.我知道我可以右键单击 res 文件夹,select“新建 > 图像资产”,但是虽然它允许我添加 select 类型的图标,但它假设我想添加一个图标。

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.我知道我可以手动生成图像并将它们移动到 drawble-mdpi、drawable-hdpi、drawable-xhdpi 中,但我认为可以自动化它并提供将缩放以创建较低分辨率版本的单个图像。

I know about Fast ways to import drawables in Android Studio?我知道在 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 .但它不限于内置选项,可接受的版本是在 2016 年收到最后更新并且似乎不再维护的插件 - NullPointerException 报告未收到维护者的回复。

You can use vector asset studio.You can also lookout below link:- Running Vector Asset Studio To start Vector Asset Studio: 您可以使用矢量资产工作室。您还可以在下面链接: - 运行Vector Asset Studio启动Vector Asset Studio:

In Android Studio, open an Android app project. 在Android Studio中,打开一个Android应用程序项目。 In the Project window, select the Android view. 在“项目”窗口中,选择Android视图。 Right-click the res folder and select New > Vector Asset. 右键单击res文件夹,然后选择“新建”>“矢量资产”。 Some other project views and folders have this menu item as well. 其他一些项目视图和文件夹也有此菜单项。

Vector Asset Studio appears. 出现Vector Asset Studio。

Importing an SVG or PSD file After you open Vector Asset Studio, you can import an SVG or PSD file as follows: 导入SVG或PSD文件打开Vector Asset Studio后,可以导入SVG或PSD文件,如下所示:

In Vector Asset Studio, select Local file. 在Vector Asset Studio中,选择“本地文件”。 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 如果SVG或PSD文件包含不受支持的功能,则Vector Asset Studio底部会显示错误

https://developer.android.com/studio/write/vector-asset-studio.html#running 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? 不幸的是,在发布和创建赏金之后,我发现它已经被问到是否有办法从大规模图像创建xxhdpi,xhdpi,hdpi,mdpi和ldpi drawables?

Therefore Is there a way to create xxhdpi, xhdpi, hdpi, mdpi and ldpi drawables from a large scale image? 因此有没有办法从大尺寸图像创建xxhdpi,xhdpi,hdpi,mdpi和ldpi drawables? 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). 选项#1:只需发送-xxhdpi drawables并让Android在运行时为您下采样(缺点:仅适用于最近的设备,其中-xxhdpi是已知的)。

Option #2: Automate the process within a graphics editor, per ssantos' answer. 选项#2:根据ssantos的回答,在图形编辑器中自动完成该过程。

Option #3: Script yourself a solution, using something like ImageMagick. 选项#3:使用ImageMagick之类的东西为自己编写解决方案。

(answers by CommonsWare) (CommonsWare的回答)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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