在 Android Studio 中导入可绘制对象的快速方法? [英] Fast ways to import drawables in Android Studio?

查看:24
本文介绍了在 Android Studio 中导入可绘制对象的快速方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Android 项目的某个时刻,您需要在 res/drawable 目录中导入一些可绘制对象 - 无论是工具栏图标、图像、UI 功能.大多数情况下,您会根据最常见的限定符(drawable-hdpidrawable-mdpidrawable-xdpidrawable-xxdpi, ...).

At some point in an Android project you will need to import some drawables - be it toolbar icons, images, UI features - in res/drawable directory. Most of the times you have images scaled for the most common qualifiers (drawable-hdpi, drawable-mdpi, drawable-xdpi, drawable-xxdpi, ...).

所以我们需要为每个可绘制对象复制/粘贴三个、四个甚至五个文件:

So we need to do three, four, even five file copy/pastes for each drawable:

external_dir/drawable-mdpi/file.png   ->  my_package/drawable-mdpi/file.png
external_dir/drawable-hdpi/file.png   ->  my_package/drawable-hdpi/file.png
external_dir/drawable-xdpi/file.png   ->  my_package/drawable-xdpi/file.png
external_dir/drawable-xxdpi/file.png  ->  my_package/drawable-xxdpi/file.png

如果您必须导入多张图片,那很烦人.是否有一种简单快捷的方法可以将 file.png 的这四个实例直接传输到相应的包文件夹中?在 IDE 中实现了一些功能?一些简单的解决方法?

That is annoying if you have to import multiple pics. Is there an easy, quick way to transfer these four instances of file.png right in the corresponding package folder? Some function implemented in the IDE? Some easy workaround?

到目前为止,我的工作流程是:

My workflow until now has been:

  • 从OS文件管理器,从外部目录复制/粘贴到包,然后在Android Studio中刷新资源文件.这意味着打开每个符合条件的子目录,所以四步;
  • 从操作系统文件管理器,移动到external_dir,搜索file.png,在一个列表中得到四个实例,拖放到Android Studio,然后对于每张图片,右键单击导航栏,在相应的包目录中CopyPaste.不是更好!
  • copy/paste from OS file manager, from the external directory to the package, and then refresh the resource files in Android Studio. That implies opening each one of the qualified subdirectories, so four moves;
  • from the OS file manager, move to external_dir, search for file.png, get the four instances in a single list, drag&drop into Android Studio, then for each pic right click on the nav bar, Copy, and Paste in the corresponding package directory. Not really better!

有什么建议吗?

编辑 - 当然,我并不是真的在寻求建议" - 我想知道是否有办法将移动次数减少到一个(或这样).

Edit - I'm not really asking for "advices" of course - I want to know if there's a way to drop the number of moves to one (or such).

推荐答案

自 Android Studio 3.4 以来,这变得更加容易.只需转到Resource Manager 选项卡,然后单击小添加按钮向模块添加资源.[

This became a lot easier since Android Studio 3.4. Simply go to the Resource Manager-tab and click the little add-button add resources to the module. [

然后选择您要导入的可绘制对象.如果您将可绘制对象放在与限定符(drawable-mdpi、drawable-hdpi、drawable-xhdpi 等)同名的文件夹中,该工具将自动知道是否要添加它们.

Then select the drawables you would like to import. If you placed the drawables in folders with the same name like the qualifiers (drawable-mdpi, drawable-hdpi. drawable-xhdpi and so on), the tool will automatically know were to add them.

在我看来,唯一仍然缺少的是将可绘制对象添加到特定的 flavorDimension 中.

The only thing still missing in my opinion is adding the drawables to a certain flavorDimension.

这篇关于在 Android Studio 中导入可绘制对象的快速方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆