I managed to clone the git repository of Material Design icons, but now I'm struggling with how to use it.
I want to use the icon resources in the XML files, in the XML attributes like android:icon="@drawable/***
.
so I searched quite many articles and none of them seems to be clear so far. Can someone explain?
The complete set of material icons are available on the material icon library. The icons are available for download in SVG or PNGs, formats that are suitable for web, Android, and iOS projects or for inclusion in any designer tools.
Google's Material Icons provides a long list of icons. Choose any one of them and add the name of the icon class to any HTML element within the < body > tag. In the following example, we have used the icon named accessibility that belongs to the action category.
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:
This example demonstrates how to use Material Design components in an Android App. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.java
Click on the marked button in the below image, to select the desired vector icons. By adding the app:icon attribute in each of the buttons and selecting the desired vector icon from the drawable folder, will add the icon to the material design buttons. So, invoke the following code. Here the icons are optional.
PNGs suitable for Android are available from the material icons library. These come in all the supported screen densities so they should look good on any device. The icons are also available in the material design icons git repository in the same combination of colors and sizes named as follows:
You don't need to clone the repository to do this. If you're using an up to date version of Android Studio you can import the individual icons you need directly.
Right-click on your drawable folder and in the menu go to New > Vector Asset. From there the default option is to select any of the Material icons to use, or you have the option to use your own SVG files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With