How to import set of icons into Android Studio project - android-studio
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?
Edit :
After Android Studios 1.5 android support Vector Asset Studio.
Follow this, which says:
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.
Old Answer
Go to Settings > Plugin > Browse Repository > Search Android Drawable Import
This plugin consists of 4 main features.
AndroidIcons Drawable Import
Material Icons Drawable Import
Scaled Drawable
Multisource-Drawable
How to Use Material Icons Drawable Import : (Android Studio 1.2)
Go to File > Setting > Other Settings > Android Drawable Import
Download Material Icon and select your downloaded path.
Now right click on project , New > Material Icon Import
Use your favorite drawable in your project.
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.
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.
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"
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):
In the Project window, select the Android view.
Right-click the res folder and select New > Vector Asset.
The Material Icon radio button should be selected; then click Choose
Select your icon, tweak any settings you need to tweak, and Finish.
Depending on your settings (see article), PNGs are generated during build at the app/build/generated/res/pngs/debug/ folder.
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.
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.
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.
Related
Could show the actual folder structure for flutter project without the dot
the flutter project I just created always contains a dot in the subfolder of src, is there a option I can disable showing the dot ?
If you are using Android Studio, In the project pane, click on the settings icon (Gear icon): In the menu (Which will pop-out) deselect the Compact Middle Packages option
difference between ic_launcher, ic_launcher_foreground and ic_launcher_round
I am using Android Studio (v 3.4.1) to create Adaptive Launcher Icons. I am confused about the PNG files it is generating. I used the Asset Studio to create Launcher Icons (Adaptive and Legacy). The process was simple enough. But I question if some of the output files are necessary. The output consists of the following: \release\res\mipmap-anydpi-v26 ic_launcher.xml ic_launcher_round.xml \release\res\mipmap-nndpi (for each pixel density) ic_launcher.png ic_launcher_foreground.png ic_launcher_round.png \release\res\values\ic_launcher_background.xml I think each \mipmap-nndpi folder only needs the [foreground & round].png files. When I created the icons manually, I did not create ic_launcher.png and didn't see a difference. Is ic_launcher.png required for minimum Target SDK 28+?
Take a look at https://github.com/Viperusgit/AdaptiveIcons ic_launcher_forground is the name of the forgound image ic_launcher is the icon for older versions of android ic_launcher_round is the icon for older pixels
File Android.png does not exist in Android Studio when create image asset
When I try to create action icon in Image Asset of Android Studio I saw the error log: Android.png does not exist and I can not create action icon. Anyone can help me? screenshot
This issue can be resolved by: Select Launcher Icons, definitely, there will be the previous linked file which was removed from the system. Just go there and choose some other file and the issue will be resolved automatically.
In my case it was an image wizard issue. Image asset wizard caches path to ic_launcher icon and can't find it. To resolve it you need repick ic_launcher image file for background layer and/or/maybe foreground layer. Also you can use such command line tool like ack to find all strings 'burma_launcher.png' and manually edit finded files
recommend that you use the material design style for action bar and tab icons, even if you support older Android versions. Use appcompat and other support libraries to deliver your material design UI to older platform versions. As an alternative to Image Asset Studio, you can use Vector Asset Studio to create action bar and tab icons. Vector drawables are appropriate for simple icons and can reduce the size of your APK.
Parent package name repeated in Android Studio project view
After refactoring the name of a base package, Android Studio now displays the full package name for all subpackages of the refactored package in the Project / Android treeview. The directory names and package declarations in the Java files are correct, so this seems to be related to an .idea file. This is what I'm seeing (The blurred package name is the same in all instances): Any suggestions? I've noticed a couple of times that the issue temporarily corrects itself while Android Studio performs a background process.
You'll want to disable flat hierarchy in Project pane. 1) Click Show Options menu button. 2) Uncheck Flatten Packages. 3) Optional: Uncheck Compact Empty Middle Package
How to create new res folder in Android Studio
I want to add localized strings for my android app. Therefore I need a values-xx folder in my Res folder. The original values folder has a blue dot, so I tried creating a new Package, but a package can't contain a hyphen so this must be wrong. Instead I tried right-clicking res and choosing New -> Android resource directory, but this time nothing happens. No dialog or reaction of any sort as I can see. How do I create a values-xx folder? Edit: I can create the folder from file explorer and it all works good. It is just irritating to not be able to do it from inside Android Studio. Edit2: This bug is fixed in newer versions of Android Studio.
When you are in the Android view (rather than Project or Packages) in Android studio, you just need to right click the "values" directory and choose New > "Values resource file". That gives you a chose of different resources you can add. For example, if you want to add a different language to your app you can choose the Language option and press the ">>" button. If you want Swahili then select that from the list, type "strings" for the file name, and press OK. Android Studio will automatically create a values-sw directory with the new strings.xml file in it. And in your Android file view you conveniently see both strings files together. And it is a similar process for adding other types of resources (see my other example). You no longer have to manually add the directories (but you can do that too by right clicking the res directory and choosing New > Android resource directory).
I had the same problem, what I did was create a values-xx folder inside the main directory (main>>right click>>new>>directory) and then moved that folder to res/ directory. It's not beautiful but it is a workaround to create a folder with Android studio.
This bug is fixed in newer versions of Android Studio.
The values-xx folder we created is not showing, but when we create a file its asking =>I have created values-21 folder and then tried with creating an xml and it asks for choosing a directory =>I have updated to Android 1.02 Check the values-21
Lets assume i Want to create a folder named "Daylight" under res. Step 1: Right click on res. Step 2: Then go to New. Step 3: Then go to Folder. Step 4: Then go to Res Folder Option and select. A window will be open. Step 5: At that window check the unchecked box "Change Folder Location" and as assumed we have to create folder "Daylight" Step 6: SO name the newly created folder as daylight, in this format. src/main/res/Daylight Step 7: Then, Finally Click finish.
If you have already created a new directory but just don't see it in the Project Tools window. Do this Click on Project Tools window >> Android(Drop Down) >> Click Project. Now you'll see all your Directories in res. See the picture:
Its very simple. I too had trouble initially. Lets break it stepwise:- 1) Open your project 2) Right click the res folder 3) Choose New 4) Chose Directory 5) Name the directory. Thats it!! It works for a fresh project everytime!
For those finding this answer when trying to add a new res folder to a library. Right-click java/kotlin folder > New > Folder > Res Folder