Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Make check icon using xml drawable

enter image description here

How can I make this shape using xml drawable? Been fighting over it quite some time and can't get it done.

like image 675
Anonymous Avatar asked Sep 08 '16 09:09

Anonymous


2 Answers

Here is the template you could improve:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:width="30dp"
        android:height="4dp"
        android:top="20dp">
        <rotate
            android:fromDegrees="45">
            <shape android:shape="rectangle">
                <solid android:color="@android:color/holo_orange_dark"/>
            </shape>
        </rotate>
    </item>

    <item
        android:width="40dp"
        android:height="4dp"
        android:top="15dp"
        android:left="18dp">
        <rotate
            android:fromDegrees="-45">
            <shape android:shape="rectangle">
                <solid android:color="@android:color/holo_orange_dark"/>
            </shape>
        </rotate>
    </item>

    <item
        android:width="50dp"
        android:height="50dp">
        <shape android:shape="rectangle">
            <solid android:color="@android:color/transparent"/>
        </shape>
    </item>
</layer-list>
like image 87
R. Zagórski Avatar answered Sep 21 '22 18:09

R. Zagórski


2020 Solution:

For anyone looking for this answer now, you can download the icon on the material website (https://material.io/resources/icons/?style=baseline)

For android, you can even directly add the icon from Android Studio using:

  • 1 -> "Resource Manager" on the left
  • 2 -> pressing the "+" icon
  • 3 -> selecting "Vector Asset"
  • 4 -> then you just have to select the proper icon

or you could:

  • 1 -> right click on the res/drawable folder
  • 2 -> select New > Vector Asset
like image 40
benjiii Avatar answered Sep 20 '22 18:09

benjiii