Applying android app icon in Android Studio - android

I have started with Android Studio a few months before. I have found many good things and a few bad as compared to eclipse. I would like to know if there is a shortcut or easy way to change the app icon...like the Eclipse IDE offers automatically... or we still need to copy and paste the various icons (hdpi, mdpi, xxhdpi) manually to the respective directories.

Right click drawable -> New -> Image Asset -> Asset Type: Action Bar and Tab Icons. Image file: image_path, Resource Name: how_youre_image_will_be_called -> Next -> Finish
Done
This will add 4 different sizes of your image so that it will fit depending the device size (phone, tablet...)

Using Android Drawable Importer Plugin you can add an option to Android Studio to import drawables in different resolutions from Android Icons.

Related

Variants of icon sizes not showing up in Android Studio

I am trying to include variations of an icon's size in my Android Studio res/drawable folder. I downloaded the icon that I wanted from material.io/icons and placed the different variants of the icon into my drawable folder.
Here is the drawable folder:
However, in Android Studo, there are no drawables found.
I am having trouble understand why this is happening because I have already created another app with images of differing sizes. That app here.
Instead of creating a drawable folder and placing each separate image into the folder, copy and paste each variant into the res directory.
Under the Project pane (on left hand side), if you have selected 'Android' menu then you can't see the different drawable folders as it merges all the folders in one. If you change the menu to 'Packages' then you would be able to see all the folders you have created manually.
Create All the drawable folders inside the res folder outside the sudio and just refresh the project inside the android studio.
As you said that you have included the icons in the drawable folders according to resolutions , so if you want to see if the icons are present in the drawable folders . You need to change the menu from "Android" to "Packages" , you should see different drawable folders and icons in the respective folders .

Sizes of an image to put as action bar

In my app I put an image as actionbar
getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.header_edea));
The code is right, but I need the sizes for the different densities (ldpi, hdpi, etc).
Check the following link:
Design layout to support multiple screen
on Android Studio, you can choose an image for different layout sizes.for example, you add that image on Project -> new -> ImageAsset and it will show you or it will create that image for different sizes with different directories.(you can see the results in different drawable folders or mipmap folder with different sizes).
And after that, you just have to choose it and it will fix that for different sizes.
Android Studio has already a tool called Asset Studio described in LinX64.
For this purpose you can also check an online tool created by Roman Nurik called Android Asset Studio, which helps you to generate all needed image sizes: https://romannurik.github.io/AndroidAssetStudio/
Check this links - the first is a guide about creating icons, the second one give you information about all needed icon sizes for Android purposes like notifications or action bar:
Google's Design -
Icons
Icon Reference
Chart
Also on StackOverlow:
Action Bar icon size
Actionbar Logo size?
Hope it help

Theare aren't different drawable folders on Android Studio

I m trying to integrate different image size in my app but the problem is that in Android Studio there are not the drawable-Idpi,mdpi,hdpi,xhdpi folders.
I ve checked already other threads and the answers were that I just need to skip into the Project view instead of the Android one. But the results are the same. There is just one generale folder called drawable
And if I try to add another resource folders the drawable is missing.
Just create a new folder:
Right click 'res' folder --> New --> Android Resource Directory.
In the wizard, select drawable as 'Resource Type'. And then 'Density' from the resource qualifiers.
With regard to the 'mipmaps' folders, Android now prefers app icons in these folders because it can use an icon in a different density to the screen density.
More about mipmaps here: http://android-developers.blogspot.de/2014/10/getting-your-apps-ready-for-nexus-6-and.html
I had the same problem before.
I fixed it by downloading an icon that i wanted from http://www.icons4android.com/
now this site provides all the drawable-Idpi,mdpi,hdpi,xhdpi folders for download for each icon they have, I just highlighted all the drawable-Idpi,mdpi,hdpi,xhdpi folders, copied them, and then pasted them to android studio res folder.
(I did this in android view)
I hope this helps
You can create folder same as drawable, drawable-hdpi, mdpi, xxhdpi ... etc
Its look like
But when you see source code using
Add images in draweble its ask you in which folder you want to add(copy n past images in studio)
You can directly creat folder in res its also work...

Android Studio. Drawables folder and sizes?

I'm an Eclipse developer and recently switched to Android Studio.
I know that "drawable" folder is where I must upload all the images I'm going to use in my Android project but, what happens with the image sizes? In Eclipse there are different folders for each size (xxhdpi, xhdpi, hdpi...)
What method should I use now to get the best compatibility with images and devices?
Thanks.
In Eclipse there are different folders for each size (xxhdpi, xhdpi, hdpi...)
They are there in Android Studio too. The Android Tools team kinda hid them.
If you look just above the project explorer tree thingy on the left, you should see a drop-down, one that probably says "Android" right now:
That is the Android project view, one that gives you a somewhat synthetic look at your project, collapsing things like resource sets and sourcesets to hide those details.
Eclipse users will probably be happier with the classic project view, which you get by clicking that drop-down and switching it to "Project":
This works much like Eclipse's Package Explorer, where you get an actual filesystem view of what's going on, complete with resource set directories.
It's all the same stuff on the filesystem, but the Android project view masks it a bit.
Right click drawable -> New -> Image Asset -> Asset Type: Action Bar and Tab Icons. Image file: image_path, Resource Name: how_youre_image_will_be_called -> Next -> Finish
Done
This will add 4 different sizes of your image so that it will fit depending the device size (phone, tablet...)
You can also ctrl+c -> ctrl+v to drawable folder and pick the size you want (mdpi - phones, xxhdpi - tablets...) but it would not resize by devices type
Studio is generate image klasor automotacly.
just suld make like this.
ic_launcher 36*36
ic_launcher 48*48
and other image resizes.
But one thing changed.Now ldpi is dont create.
The easiest way is to use Resource Manager, it allows to upload our images from Android studio itself and then resize it with each density

Set icon for Android application

How can I set an icon for my Android application?
If you intend on your application being available on a large range of devices, you should place your application icon into the different res/drawable... folders provided. In each of these folders, you should include a 48dp sized icon:
drawable-ldpi (120 dpi, Low density screen) - 36px x 36px
drawable-mdpi (160 dpi, Medium density screen) - 48px x 48px
drawable-hdpi (240 dpi, High density screen) - 72px x 72px
drawable-xhdpi (320 dpi, Extra-high density screen) - 96px x 96px
drawable-xxhdpi (480 dpi, Extra-extra-high density screen) - 144px x 144px
drawable-xxxhdpi (640 dpi, Extra-extra-extra-high density screen) - 192px x 192px
You may then define the icon in your AndroidManifest.xml file as such:
<application android:icon="#drawable/icon_name" android:label="#string/app_name" >
....
</application>
Add an application launcher icon with automatic sizing.
(Android studio)
Go to menu File* → New → Image Assets → select launcher icon → choose image file.
It will automatically re-size.
Done!
I found this tool the most useful.
Upload an image.
Download a zip.
Extract it into your project.
Done
https://romannurik.github.io/AndroidAssetStudio/
It's better to do this through Android Studio rather than the file browser as it updates all icon files with the correct resolution for each.
To do so go to menu File → New → Image Asset. This will open a new dialogue and then make sure Launcher Icons is selected (Which it is by default) and then browse to the directory of your icon (it doesn't have to be in the project resources) and then once selected make sure other settings are to your liking and hit done.
Now all resolutions are saved into their respective folders, and you don't have to worry about copying it yourself or using tools, etc.
Don't forget "Shape - none" for a transparent background.
Please don't edit my answer without asking.
Put your images in mipmap folder and set in manifest file...
like as
<application android:icon="#mipmap/icon" android:label="#string/app_name" >
....
</application>
App Folder Directory :
Icon Size & Format :
Place your images in drawables folder under either of the three and set it like this.
Code
<application android:icon="#drawable/your_icon" >
....
</application>
Right click your project, go to New > Other > Android > Android Icon Set
Then follow the instructions on the Wizard
1-Create Your icon in Photoshop Or Coreldraw by size 256*256
note that use PNG file format if you want to have a transparent icon
2-Upload Your icon in https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html
3-Set your setting on this site
4-Download the zip file automatically created by the webpage by clicking on download button
5-Extract the zip file and copy res folder to you project library
note that res folder contain all size icon
6-finally you need to set the manifest to use icon
<application android:icon="#drawable/your_icon" >
....
</application>
You can simply install an Android studio Martial icons plugin its name is please check plugin URL Material Design Icon Generator and check this GIF for more details:
This is mainly for creating the icons with required sizes, and it will be located directly in its folders.
I found all these answers that used to be solid answers to be a bit dated now. I reckon this will be the fate of this answer someday.
Click on your main project, most people would have "app" as their main project name by default. I like to be specific since I have other projects as well.
[your project name|app]->"New"->"Image Asset"
Then you will get to pick an image. I chose once that wasn't the greatest fit. Notice the tool shows you the "safe zone".
You can sample the different resolutions. Change the name, etc. The default name is "ic_launcher". I prefer to be expressive with the name so there is no confusion later which ic_launcher this belongs too.
Choose "Next", make changes if you need to, and ultimately "Finish". I found the rest of the tool to be self explanatory. For more info I suggest reading the manual that describes all these settings in more detail: Android Studio Image Asset Tool Documentation
On "Finish" this will put the files into the respective folders under the expected "res" folder.
The next thing you have to do is have to tell the project that's the icon you want to use. Inside the AndroidManifest.xml do something like the following (using your own name you chose to use above.)
<application
android:icon="#mipmap/pooflingers_ic_launcher">
That's pretty much it, as of today anyway... I am using Android Studio v4.2.1 Let me know when these steps become out of date.
You have to follow steps like:
You will see your default icons ic_launcher.png like:
You have to change all the images which are in mipmap-xxxx folders.
First of you have to create your own logo or pick up image that you want to place as icon of launcher and upload here Android Asset Studio - Icon Generator - Launcher icons, You will get all the set of mipmap-xxxx and web_icon also from that link.
Now you have to copy all the folders which are in side of res folder,
Now go to Android Studio Project -> Right click on res folder -> Paste. It will prompt you like File 'ic_launcher.png' already exists in directory, You can press Overwrite all. It will paste/replace images in respective folder.
Now you can run and see your application icon with new image.
Happy Coding :) :)
Choose icon picture copy this pic
Paste it into your project's res/drawable folder
Open manifest file and set
Run program
If you have an SVG icon, you can use this script to generate your android icon set.
In AndroidManifest change these :
android:icon="#drawable/icon_name"
android:roundIcon="#drawable/icon_name"
Define the icon for android application
<application android:icon="drawable resource">
....
</application>
https://developer.android.com/guide/topics/manifest/application-element.html
If your app available across large range of devices
You should create separate icons for all generalized screen densities,
including low-, medium-, high-, and extra-high-density screens. This
ensures that your icons will display properly across the range of
devices on which your application can be installed...
Size & Format
Launcher icons should be 32-bit PNGs with an alpha channel for
transparency. The finished launcher icon dimensions corresponding to a
given generalized screen density are shown in the table below.
Place icon in mipmap or drawable folder
android:icon="#drawable/icon_name" or android:icon="#mipmap/icon_name"
developer.android.com/guide says,
This attribute must be set as a reference to a drawable resource
containing the image (for example "#drawable/icon").
about launcher icons android-developers.googleblog.com says,
It’s best practice to place your app icons in mipmap- folders (not the
drawable- folders) because they are used at resolutions different from
the device’s current density. For example, an xxxhdpi app icon can be
used on the launcher for an xxhdpi device.
Dianne Hackborn from Google (Android Framework) says,
If you are building different versions of your app for different
densities, you should know about the "mipmap" resource directory.
This is exactly like "drawable" resources, except it does not
participate in density stripping when creating the different apk
targets.
For launcher icons, the AndroidManifest.xml file must reference the mipmap/ location
<application android:name="ApplicationTitle"
android:label="#string/app_label"
android:icon="#mipmap/ic_launcher" >
Little bit more quoting this
You want to load an image for your device density and you are going to use it "as is", without changing its actual size. In this case you should work with drawables and Android will give you the best fitting image.
You want to load an image for your device density, but this image is going to be scaled up or down. For instance this is needed when you want to show a bigger launcher icon, or you have an animation, which increases image's size. In such cases, to ensure best image quality, you should put your image into mipmap folder. What Android will do is, it will try to pick up the image from a higher density bucket instead of scaling it up. This will increase sharpness (quality) of the image.
Fore more you can read mipmap vs drawable folders
Tools to easily generate assets
Android Asset Studio by romannurik.github
Android Asset Studio by jgilfelt.github
Image Asset Studio(from Android Studio)
Material Icon Generator.bitdroid.de
Android Material Design Icon Generator Plugin by github.com/konifar
A script to generate android assets from a SVG file
Read more : https://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html
A bit old, but for future use:
Open Android Studio -> app/src/main/res -> Right Click -> Image Asset
Goto File->new->ImageAsset.
From their you can create Image Assets for your icon.
After that we will get icon image in mipmap different formats like
hdpi,mdpi,xhdpi,xxhdpi,xxxhdpi.
Now goto AndroidManifest.xml
<application android:icon="#mipmap/your_Icon"> ....</application>

Categories

Resources