如何将图像导入或复制到Android Studio的“res”文件夹中?

时间:2021-08-04 00:28:43

I can save all my images directly in the res/drawable-xxx folder.

我可以将所有的图像直接保存在res/ draw- xxx文件夹中。

But how can I import/copy images to my project from Android Studio?

但是如何从Android Studio导入/复制图像到我的项目中呢?

If I drag an drop my images from the Finder (MacOS), the files only move to the res folder.

如果我从查找程序(MacOS)拖拽图像,文件只会移动到res文件夹。

At in the context-menu there is no Import... and under New... there is also not.

在上下文菜单中没有导入…和在新…也不是。

9 个解决方案

#1


85  

  1. Go to your image in windows, then press ctrl + c OR Right click and Copy

    转到窗口中的图像,然后按ctrl + c或右键单击并复制

  2. Go to Your res Folder And choose One of the folders(eg. MDPI, HDPI..) and press ctrl + v OR right click it and Paste

    进入你的res文件夹,选择一个文件夹(例如。然后按ctrl + v或右键点击粘贴

#2


48  

Goto Settings > Plugin > Browse Repository > Serach Android Drawable Import

Goto设置>插件>浏览库> Serach Android可提取导入

This plugin consists of 4 main features.

这个插件包含4个主要特性。

  • AndroidIcons Drawable Import
  • AndroidIcons可拉的进口
  • Material Icons Drawable Import
  • 材料图标可拉的进口
  • Scaled Drawable
  • 可拉的比例
  • Multisource-Drawable
  • Multisource-Drawable

Edit : After Android Studios 1.5 android support Vector Asset Studio.

编辑:Android Studio 1.5后支持向量资产工作室。


Follow this, which says:

遵循这个,说:

To start Vector Asset Studio:

启动矢量资产工作室:

  1. In Android Studio, open an Android app project.
  2. 在Android Studio中,打开一个Android应用程序项目。
  3. In the Project window, select the Android view.
  4. 在项目窗口中,选择Android视图。
  5. Right-click the res folder and select New > Vector Asset.
  6. 右键单击res文件夹并选择新的>向量资产。

如何将图像导入或复制到Android Studio的“res”文件夹中?

#3


5  

  1. go to your image in windows and copy it
  2. 进入你的图像在窗口和拷贝它
  3. go to the res folder and select one of the drawable folders and paste the image in there
  4. 转到res文件夹,选择一个可绘制的文件夹并将图像粘贴到其中
  5. click on imageview then go to properties and scroll down until you see src
  6. 单击imageview,然后转到属性并向下滚动,直到看到src
  7. insert this into src @drawable/imagename
  8. 插入到src @drawable/imagename中

#4


3  

To import files from OS X Finder into Android Studio, just drag the relevant files to your resource folder.

要从OS X Finder中导入文件到Android Studio中,只需将相关文件拖到资源文件夹即可。

  • Drag & Drop by default moves files to your project (not what you always want)
  • 在默认情况下,拖放将文件移动到项目中(而不是您一直想要的)
  • Pressing ⎇ (Alt) while dragging copies files
  • 紧迫⎇(Alt),拖动文件副本

Don't find a permanent config option for this, but this is the workaround I'm using

不要为它找到一个永久的配置选项,但这是我正在使用的解决方案

#5


3  

If you want to do this easily from within Android Studio then on the left side, right above your file directory you will see a dropdown with options on how to view your files like:

如果你想在Android Studio中轻松做到这一点,那么在你的文件目录的左边,在你的文件目录的右边,你会看到一个下拉菜单,里面有如何查看文件的选项,比如:

Project, Android, and Packages, plus a list of Scopes.

项目、Android和包,以及范围列表。

If you are on Android it makes it hard to see when you add new folders or assets to your project - BUT if you change the dropdown to PROJECT then the file directory will match the file system on your computer, then go to:

如果你在Android上,你会很难看到你在你的项目中添加了新的文件夹或资产——但是如果你将下拉菜单改为项目,那么文件目录将会与你电脑上的文件系统相匹配,然后去:

app > src > main > res

app > src >主> res

From here you can find the conventional Eclipse type files like drawable/drawable-hdpi/drawable-mdpi and so on where you can easily drag and drop files into or import into and instantly see them. As soon as you see your files here they will be available when going to assign image src's and so on.

从这里您可以找到常规的Eclipse类型文件,如可绘制/可绘制-hdpi/可绘制-mdpi等,在这些文件中您可以轻松地将文件拖放到或导入并立即看到它们。一旦你在这里看到你的文件,它们将在分配图像src时可用。

Good luck Android Warriors in a strange new world!

幸运的Android战士在一个陌生的新世界!

#6


3  

For Mac + Android Studio 2.1, I found the best way is to save the image and then copy (cmd + c) the image file in Finder and then click on the the drawable directory and cmd + v to paste in that directory. Copying the image directly from a website using cmd + c (or right click then copy) doesn't seem to work.

对于Mac + Android Studio 2.1,我发现最好的方法是保存图像,然后在Finder中复制(cmd + c)图像文件,然后点击可拖动目录和cmd + v来粘贴到该目录中。使用cmd + c(或右击然后复制)直接从网站上复制图像似乎行不通。

#7


2  

For Android Studio:

为Android工作室:

Right click on res, new Image Asset

右键单击res,新的图像资产

Select the image radio button in 3rd option i.e Asset Type

选择第三个选项i中的图像单选按钮。e资产类型

Select the path of the image and click next and then finish

选择图像的路径,然后单击next,然后单击finish。

All the images are added to the respective folder, its very simple

所有的图像都添加到相应的文件夹中,非常简单。

#8


0  

You can simply use the terminal that comes with Android Studio. It is listed at the bottom of Android Studio. Just open it and use the cp command.

你可以使用Android Studio附带的终端。它被列在Android Studio的底部。只需打开它并使用cp命令。

#9


0  

I'm in Mac OSX as well and in a new project I need to:

我也在Mac OSX,在一个新项目中,我需要:

  • Right click on res folder in the project and add a new Android resource directory.
  • 右键单击项目中的res文件夹并添加一个新的Android资源目录。
  • Select drawable from the drop down and Accept.
  • 从下拉菜单中选择drawable并接受。
  • Copy and paste the image into the drawable folder.
  • 复制并粘贴图像到可绘制文件夹中。

Disclaimer : This does NOT cover different resolutions etc.

免责声明:这并不包括不同的决议等等。

#1


85  

  1. Go to your image in windows, then press ctrl + c OR Right click and Copy

    转到窗口中的图像,然后按ctrl + c或右键单击并复制

  2. Go to Your res Folder And choose One of the folders(eg. MDPI, HDPI..) and press ctrl + v OR right click it and Paste

    进入你的res文件夹,选择一个文件夹(例如。然后按ctrl + v或右键点击粘贴

#2


48  

Goto Settings > Plugin > Browse Repository > Serach Android Drawable Import

Goto设置>插件>浏览库> Serach Android可提取导入

This plugin consists of 4 main features.

这个插件包含4个主要特性。

  • AndroidIcons Drawable Import
  • AndroidIcons可拉的进口
  • Material Icons Drawable Import
  • 材料图标可拉的进口
  • Scaled Drawable
  • 可拉的比例
  • Multisource-Drawable
  • Multisource-Drawable

Edit : After Android Studios 1.5 android support Vector Asset Studio.

编辑:Android Studio 1.5后支持向量资产工作室。


Follow this, which says:

遵循这个,说:

To start Vector Asset Studio:

启动矢量资产工作室:

  1. In Android Studio, open an Android app project.
  2. 在Android Studio中,打开一个Android应用程序项目。
  3. In the Project window, select the Android view.
  4. 在项目窗口中,选择Android视图。
  5. Right-click the res folder and select New > Vector Asset.
  6. 右键单击res文件夹并选择新的>向量资产。

如何将图像导入或复制到Android Studio的“res”文件夹中?

#3


5  

  1. go to your image in windows and copy it
  2. 进入你的图像在窗口和拷贝它
  3. go to the res folder and select one of the drawable folders and paste the image in there
  4. 转到res文件夹,选择一个可绘制的文件夹并将图像粘贴到其中
  5. click on imageview then go to properties and scroll down until you see src
  6. 单击imageview,然后转到属性并向下滚动,直到看到src
  7. insert this into src @drawable/imagename
  8. 插入到src @drawable/imagename中

#4


3  

To import files from OS X Finder into Android Studio, just drag the relevant files to your resource folder.

要从OS X Finder中导入文件到Android Studio中,只需将相关文件拖到资源文件夹即可。

  • Drag & Drop by default moves files to your project (not what you always want)
  • 在默认情况下,拖放将文件移动到项目中(而不是您一直想要的)
  • Pressing ⎇ (Alt) while dragging copies files
  • 紧迫⎇(Alt),拖动文件副本

Don't find a permanent config option for this, but this is the workaround I'm using

不要为它找到一个永久的配置选项,但这是我正在使用的解决方案

#5


3  

If you want to do this easily from within Android Studio then on the left side, right above your file directory you will see a dropdown with options on how to view your files like:

如果你想在Android Studio中轻松做到这一点,那么在你的文件目录的左边,在你的文件目录的右边,你会看到一个下拉菜单,里面有如何查看文件的选项,比如:

Project, Android, and Packages, plus a list of Scopes.

项目、Android和包,以及范围列表。

If you are on Android it makes it hard to see when you add new folders or assets to your project - BUT if you change the dropdown to PROJECT then the file directory will match the file system on your computer, then go to:

如果你在Android上,你会很难看到你在你的项目中添加了新的文件夹或资产——但是如果你将下拉菜单改为项目,那么文件目录将会与你电脑上的文件系统相匹配,然后去:

app > src > main > res

app > src >主> res

From here you can find the conventional Eclipse type files like drawable/drawable-hdpi/drawable-mdpi and so on where you can easily drag and drop files into or import into and instantly see them. As soon as you see your files here they will be available when going to assign image src's and so on.

从这里您可以找到常规的Eclipse类型文件,如可绘制/可绘制-hdpi/可绘制-mdpi等,在这些文件中您可以轻松地将文件拖放到或导入并立即看到它们。一旦你在这里看到你的文件,它们将在分配图像src时可用。

Good luck Android Warriors in a strange new world!

幸运的Android战士在一个陌生的新世界!

#6


3  

For Mac + Android Studio 2.1, I found the best way is to save the image and then copy (cmd + c) the image file in Finder and then click on the the drawable directory and cmd + v to paste in that directory. Copying the image directly from a website using cmd + c (or right click then copy) doesn't seem to work.

对于Mac + Android Studio 2.1,我发现最好的方法是保存图像,然后在Finder中复制(cmd + c)图像文件,然后点击可拖动目录和cmd + v来粘贴到该目录中。使用cmd + c(或右击然后复制)直接从网站上复制图像似乎行不通。

#7


2  

For Android Studio:

为Android工作室:

Right click on res, new Image Asset

右键单击res,新的图像资产

Select the image radio button in 3rd option i.e Asset Type

选择第三个选项i中的图像单选按钮。e资产类型

Select the path of the image and click next and then finish

选择图像的路径,然后单击next,然后单击finish。

All the images are added to the respective folder, its very simple

所有的图像都添加到相应的文件夹中,非常简单。

#8


0  

You can simply use the terminal that comes with Android Studio. It is listed at the bottom of Android Studio. Just open it and use the cp command.

你可以使用Android Studio附带的终端。它被列在Android Studio的底部。只需打开它并使用cp命令。

#9


0  

I'm in Mac OSX as well and in a new project I need to:

我也在Mac OSX,在一个新项目中,我需要:

  • Right click on res folder in the project and add a new Android resource directory.
  • 右键单击项目中的res文件夹并添加一个新的Android资源目录。
  • Select drawable from the drop down and Accept.
  • 从下拉菜单中选择drawable并接受。
  • Copy and paste the image into the drawable folder.
  • 复制并粘贴图像到可绘制文件夹中。

Disclaimer : This does NOT cover different resolutions etc.

免责声明:这并不包括不同的决议等等。