69

I downloaded collection of icons from Android Developers center Each icon in this collection is ordered in forlders according to its resolution: drawable-hdpi, drawable-mdpi, drawable-xhdpi, drawable-xxhdpi.

Is there a way to import all the 4 icon's files in one action to Android Studio or I need to copy it one by one? (when I used new->Image Asset , I had to fill a file path, I couldn't fill it with folder path)

Update 25/2/15:
According to this SO question, seems like there is a way to generate the 4 size of icons by Android Asset Studio, and then import the zip file directly to your Android Studio project res folder - has anyone used it?

Community
  • 1
  • 1
GyRo
  • 2,586
  • 5
  • 30
  • 38
  • 1
    Man copy it one by one, there's no other way. – Apurva Feb 24 '15 at 16:06
  • All this concept is unclear to me: for example when I add 'image asset' I can select asset-type and theme - where are these properties saved under the 'src' folder of the project? – GyRo Feb 24 '15 at 16:22
  • If you import via image asset then your images will be imported in res/drawable – Apurva Feb 24 '15 at 16:24
  • @Apurva its not always true.In new version of android studio if you import a launcher icon via image asset then it will go in res/mipmap instead. – Mohit Feb 24 '15 at 16:59
  • Possible duplicate of [Fast ways to import drawables in Android Studio?](http://stackoverflow.com/questions/28503229/fast-ways-to-import-drawables-in-android-studio) – TooCool Nov 19 '15 at 14:19

8 Answers8

140

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


Follow this, which says:

To start Vector Asset Studio:

  1. In Android Studio, open an Android app project.
  2. In the Project window, select the Android view.
  3. Right-click the res folder and select New > Vector Asset.

enter image description here


Old Answer

Go to Settings > Plugin > Browse Repository > Search Android Drawable Import

This plugin consists of 4 main features.

  1. AndroidIcons Drawable Import
  2. Material Icons Drawable Import
  3. Scaled Drawable
  4. Multisource-Drawable

How to Use Material Icons Drawable Import : (Android Studio 1.2)

  • Go to File > Setting > Other Settings > Android Drawable Import

enter image description here

  • Download Material Icon and select your downloaded path.

enter image description here

  • Now right click on project , New > Material Icon Import

enter image description here

  • Use your favorite drawable in your project.

enter image description here

Kishan Vaghela
  • 7,678
  • 5
  • 42
  • 67
  • 1
    I installed it but can't use it. I have to provide through IDE settings-->Android Drawable Importer - a path to the asset's home folder but there is no way to edit the field to provide this folder path. besides I don't know what's my project's asset's folder. It only have the icons under res\drawable-mdpi, res\drawable-hdpi, etc. – GyRo Feb 25 '15 at 10:49
  • U have to provide your downloaded icon folder path not your assets folder – Kishan Vaghela Feb 26 '15 at 14:05
  • U can download Material Icon from https://github.com/google/material-design-icons/releases and use downloaded folder path – Kishan Vaghela Feb 26 '15 at 14:06
  • and then what, how do I use this plugin? Right clicking the drawable folder gives me nothing. – Frank Mar 05 '15 at 09:02
  • Right Click > New > Select your Configured option for this plugin – Kishan Vaghela Mar 05 '15 at 12:58
  • 1
    Eventually I figured that it this is what I've been looking for. I am using the option new->scaled drawable that was added by this plugin, in order to import images to Android Studio. Thanks! – GyRo Mar 18 '15 at 13:20
  • @KishanVaghela can you please explain how to set the path of Material icos root folder for `Android Drawable Importer` plugin? – Shajeel Afzal May 02 '15 at 10:32
  • @KishanVaghela thank you so much for the Edit, it is much more clear and easy now. – Shajeel Afzal May 04 '15 at 11:37
  • 2
    In Android Studio 1.3 the plugin (as the field Other Settings) doesn't appear under the Settings – Evgeniy Mishustin Nov 18 '15 at 12:39
  • @LuciusHipan This screenshots from Android Studio 1.2, If you have Android Studio v1.3 or above you can find from search. – Kishan Vaghela Nov 19 '15 at 06:40
  • 2
    @Kishan Vaghela, thank you. In Android Studio 1.3 you can simply skip this step. After you download plugin and restart the studio, the plugin appears already in the "New" section (imho it downloads the icons in the runtime) – Evgeniy Mishustin Nov 19 '15 at 08:34
  • @KishanVaghela Is there a way to get grey icons? I don't want just black and white and lots of the default Android icons are in a dark grey. – edwoollard Jun 08 '16 at 16:08
  • In Android Studio 2.2 theres an option to add icons from the icon set. Rightclick the `res` folder and choose New > Image Asset. You are now in "Asset Studio" where you can simply select a theme and clipart and Bob's your uncle. – Barry Staes Oct 04 '16 at 13:38
20

Actually if you downloaded the icons pack from the android web site, you will see that you have one folder per resolution named drawable-mdpi etc. Copy all folders into the res (not the drawable) folder in Android Studio. This will automatically make all the different resolution of the icon available.

Gregory Seront
  • 201
  • 2
  • 3
9

For custom images you created yourself, you can do without the plugin:

Right click on res folder, selecting New > Image Asset. browse image file. Select the largest image you have.

It will create all densities for you. Make sure you select an original image, not an asset studio image with an alpha, or you will semi-transpartent it twice.

Frank
  • 12,010
  • 8
  • 61
  • 78
1

If for some reason you don't want to use the plugin, then here's the script you can use to copy the resources to your android studio project:

echo "..:: Copying resources ::.."
echo "Enter folder:"
read srcFolder
echo "Enter filename with extension:"
read srcFile
cp /Users/YOUR_USER/Downloads/material-design-icons-master/"$srcFolder"/drawable-xxxhdpi/"$srcFile" /Users/YOUR_USER/AndroidStudioProjects/YOUR_PROJECT/app/src/main/res/drawable-xxxhdpi/"$srcFile"/
echo "xxxhdpi copied"
cp /Users/YOUR_USER/Downloads/material-design-icons-master/"$srcFolder"/drawable-xxhdpi/"$srcFile" /Users/YOUR_USER/AndroidStudioProjects/YOUR_PROJECT/app/src/main/res/drawable-xxhdpi/"$srcFile"/
echo "xxhdpi copied"
cp /Users/YOUR_USER/Downloads/material-design-icons-master/"$srcFolder"/drawable-xhdpi/"$srcFile" /Users/YOUR_USER/AndroidStudioProjects/YOUR_PROJECT/app/src/main/res/drawable-xhdpi/"$srcFile"/
echo "xhdpi copied"
cp /Users/YOUR_USER/Downloads/material-design-icons-master/"$srcFolder"/drawable-hdpi/"$srcFile" /Users/YOUR_USER/AndroidStudioProjects/YOUR_PROJECT/app/src/main/res/drawable-hdpi/"$srcFile"/
echo "hdpi copied"
cp /Users/YOUR_USER/Downloads/material-design-icons-master/"$srcFolder"/drawable-mdpi/"$srcFile" /Users/YOUR_USER/AndroidStudioProjects/YOUR_PROJECT/app/src/main/res/drawable-mdpi/"$srcFile"/
echo "mdpi copied"
penduDev
  • 4,743
  • 35
  • 37
1

Newer versions of Android support vector graphics, which is preferred over PNG icons. Android Studio 2.1.2 (and probably earlier versions) comes with Vector Asset Studio, which will automatically create PNG files for vector graphics that you add.

The Vector Asset Studio supports importing vector icons from the SDK, as well as your own SVG files.

This article describes Vector Asset Studio: https://developer.android.com/studio/write/vector-asset-studio.html

Summary for how to add a vector graphic with PNG files (partially copied from that URL):

  1. In the Project window, select the Android view.
  2. Right-click the res folder and select New > Vector Asset.
  3. The Material Icon radio button should be selected; then click Choose
  4. Select your icon, tweak any settings you need to tweak, and Finish.
  5. Depending on your settings (see article), PNGs are generated during build at the app/build/generated/res/pngs/debug/ folder.
Jason Capriotti
  • 1,836
  • 2
  • 17
  • 33
1

just like Gregory Seront said here:

Actually if you downloaded the icons pack from the android web site, you will see that you have one folder per resolution named drawable-mdpi etc. Copy all folders into the res (not the drawable) folder in Android Studio. This will automatically make all the different resolution of the icon available.

but if your not getting the images from a generator site (maybe your UX team provides them), just make sure your folders are named drawable-hdpi, drawable-mdpi, etc. then in mac select all folders by holding shift and then copy them (DO NOT DRAG). Paste the folders into the res folder. android will take care of the rest and copy all drawables into the correct folder.

j2emanue
  • 60,549
  • 65
  • 286
  • 456
1

Since Android Studio 3.4, there is a new tool called Resource manager. It supports importing many drawables at once (vectors, pngs, ...) . Follow the official documentation.

Vít Kapitola
  • 499
  • 1
  • 5
  • 9
0

what u need to do is icons downloaded from material design, open that folder there are lots of icons categories specified, open any of it choose any icon and go to this folder -> drawable-anydpi-v21. this folder contains xml files copy any xml file and paste it to this location -> C:\Users\Username\AndroidStudioProjects\ur project name\app\src\main\res\drawable. That's it !! now you can use the icon in ur project.