Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - How to make the XML file for a icon?

This is the xml file for the SHARE icon. How do I create XML for other icons?

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
    android:fillColor="#FF000000"
    android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z" />

like image 243
Rashim Catalan Dhaubanjar Avatar asked Oct 28 '15 03:10

Rashim Catalan Dhaubanjar


People also ask

How do I make my own icons for Android?

To create a custom app icon, you'll need a third-party launcher app like Nova Launcher, which is one of the most popular. Launch the app and quickly go through the setup stage. Once you're done, find the app you want to set a custom icon for and long-tap on it. From the menu that pops up, select “Edit.”

Do Android apps use XML?

eXtensible Markup Language, or XML: A markup language created as a standard way to encode data in internet-based applications. Android applications use XML to create layout files. Unlike HTML, XML is case-sensitive, requires each tag be closed, and preserves whitespace.

What is XML file in Android?

XML stands for eXtensible Markup Language, which is a way of describing data using a text-based document. Because XML is extensible and very flexible, it's used for many different things, including defining the UI layout of Android apps.


2 Answers

If you're using an up to date version of Android Studio then right click on your drawable folder. Go to New > Vector Asset. This opens the Vector Asset Studio.

From here you can either select from a wide range of provided Material Design icons, or import your own svg if you want to.(importing an svg might not work properly in all cases)

like image 171
Lewis McGeary Avatar answered Sep 29 '22 19:09

Lewis McGeary


Android Assets studio is not an "All in One" option as it misses many basic icons like that of google, LinkedIn etc even in the new version Android Studio, so for missing icons, a simple way would be to first download your desired image in SVG format, then go to drawable>New>Vector Asset and select Local file(SVG, PSD), locate your SVG File and click Next>Finish.

Now that file is converted into an XML File, very easy, you can now change its colors/size also in code of XML.

like image 27
Syed Faisal Avatar answered Sep 29 '22 19:09

Syed Faisal