Use Material Icons in XML - android

I want to use the new material icons provided by Google. I find it a bit cumbersome to download each icon individually.
Is there a way to do something like:
<ImageButton
android:src="#android:Icon.Material.IconName"
.../>
If not, whats the easiest way to include multiple icons in my project?
Cheers.

Follow these steps 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.
After you open Vector Asset Studio, you can add a material icon as follows:
Select "Material Icon"
Click Choose
Select a material icon

Checkout if this can be helpful:
https://github.com/google/material-design-icons

Related

How can I use outlined Material icons in Android Studio?

I would like to use outlined Material icons in my Android Studio project but I'm not able to find how. I've searched on Google similar questions and only found this unanswered question. I've also searched on the Material Design website, but the "copy" icon doesn't appears in it...
So, how can I use outlined Material icons ?
You can switch to outlined icons in the drop down menu.
Right-click the res > drawable folder in the Explorer area on the left of Android Studio. From the menu that appears, select New > Vector Asset

Default Android player icons?

Does Android have default play/pause control icons?
I found Where can I find Android's default icons? , there are many folders here. I searched for "play", "pause" in file names and nothing showed up.
Where can I find Android's default playback control icons?
System default icons listed:
https://developer.android.com/reference/android/R.drawable.html
And call the resource in this way:
android.R.drawable.ic_media_play or .ic_media_pause, enjoy autocomplete
You can find google's material design icons here, in av folder you should find play and pause.
If you're using Android Studio and you're ok with vector drawables, right click on drawable folder -> new -> vector assets -> select "material icon" -> click on "icon" -> choose the one you want, should be looking again in "av" folder
If by chance you're using ExoPlayer, they distribute icons in their ui module

Create Circular Launcher Icon

I am trying to create circular launcher icons in Android Studio 2.2 but they keep coming out square. Has anyone else encountered this? Am I doing something wrong?
After clicking Next you should get circular launcher icon.
Previews might be misleading as they have background as the icon.
After all, if you won't get what you expect, try: https://romannurik.github.io/AndroidAssetStudio/
Hope it will help
Set the project structure to Android
For app module :-
1. Select app-> res
2. Right click on res folder, click on Image Asset
3. In Legacy tab set the shape to Circle
For wear module :-
1. Select wear-> res
2. Right click on res folder, click on Image Asset
3. In Legacy tab set the shape to Circle
Go to under "File > New > Asset Studio", then look for Foreground, Background, Legacy.
Click on Legacy and
choose "circle" from the drop-down menu under "shape".

how to add material design icons-font to an Android app

In my app there are a lot of places where i have to programmatically add icons into my textviews.
On the Android material design website i saw, that you can use icon fonts, but there is nothing that indicates that you can do this inside an android app, lose from the png and svg icons itself.
http://google.github.io/material-design-icons/
is it possible to use icon-fonts in android? and if it is possible how do i implemented this into my app?
can someone help me with this?.
With the latest version of the Android Studio, you can now generate the Material icon by
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.
Vector images can also be generated by selecting vector image option
More information about vector assets can be found here https://developer.android.com/studio/write/vector-asset-studio
You could have a look at the Android-Ionics library: https://github.com/mikepenz/Android-Iconics
It has many built-in fonts including the Material Design Icon Font and can be used for ImageViews, TextViews and Buttons.
Apart from that you can use the Material Design Icon Font like any other font:
Download .ttf file and save it under main/assets/fonts
Define strings for the unicode values you need, e.g. something like
<string name="myicon"></string>
Load typeface in your application and set typeface for textview
Use string myicon as text in your textview
Unfortunately I can't find built-in solution for this, but you can check this samples with external libs
http://blog.shamanland.com/2013/11/how-to-use-icon-fonts-in-android.html
http://fortawesome.github.io/Font-Awesome/icon/android/
http://code.tutsplus.com/tutorials/how-to-use-fontawesome-in-an-android-app--cms-24167

Where are the drawables or clipart from android.R.drawable stored?

I am integrating ActionBarSherlock in my app and I want to have some menus with some items and its respective icons.
I have looked into samples and documentation, and everything seems to be clear, but when I Inflate the menu, I can see just the text because there are no icons related to each item yet.
I would like to use the icons you see when creating an android project:
But I can't find it, and I don't want to use direct reference to android.R.drawable in order to use those clipart icons, because I have read it is recommended to have the files in drawable folders.
android-sdk/platforms/android-xx/data/res/drawable-yyyy
where xx is your target platform and yyyy is mdpi, hdpi, etc.
Copy the icons you want into the appropriate resource folder in your project.
I generally use Android Asset Studio to create icons for my apps. It has all the standard clipart, and can generate the proper files for all other icons as well.
http://developer.android.com/design/downloads/index.html site has Action Bar Icon Pack
You can use system icons by using "#android:" prefix. The icon is not copied to drawable folders, so the application size is smaller"
Example: android:icon="#android:drawable/ic_menu_preferences"
List of icons at /platforms/android-/data/res/drawable-hdpi
Note 1: If you want to copy the icons to drawable files you can also do it in eclipse by using file /new/other/Anddoid icon set/clipart button/choose button.
Note 2: the icon set could change among platforms. That is why people are suggesting to copy resources. If the applicacion is just at development state you could just link the platform icons

Categories

Resources