androidandroid-layoutemojixml-drawable

How to create a smiley face drawable XML in Android?


How to create an XML Drawable, in Android, that looks like a smiley face, which I can use as background for my layout views?

I want the Drawable to look like this:

Please help! Thanks!!!


Solution

  • Here is the process if you want to create icons in XML. It's pretty simple. First you will need to find the svg icon or create one, a great resource to find free icons is https://www.flaticon.com/

    Then you will need to convert your svg icon to xml, there are many online website that do this. In this case i used https://svg2vector.com/

    Here is the smiley icon.

    <vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt"
        android:viewportWidth="567.419"
        android:viewportHeight="567.419"
        android:width="567.419dp"
        android:height="567.419dp">
        <path
            android:pathData="M409.93 209.297c0 18.056 -14.627 32.692 -32.683 32.692c-18.047 0 -32.683 -14.636 -32.683 -32.692s14.636 -32.683 32.683 -32.683C395.303 176.614 409.93 191.241 409.93 209.297z"
            android:fillColor="@android:color/holo_orange_dark" />
        <path
            android:pathData="M222.011 209.297c0 18.056 -14.636 32.692 -32.683 32.692s-32.683 -14.636 -32.683 -32.692s14.636 -32.683 32.683 -32.683S222.011 191.241 222.011 209.297z"
            android:fillColor="@android:color/holo_orange_dark" />
        <path
            android:pathData="M308.702 451.466h-45.388c-57.483 0 -104.253 -46.205 -104.253 -103.014c0 -7.443 6.034 -13.468 13.468 -13.468c7.434 0 13.468 6.025 13.468 13.468c0 42.659 33.958 76.078 77.317 76.078h45.388c43.359 0 77.317 -32.863 77.317 -74.821c0 -7.443 6.034 -13.468 13.468 -13.468c7.443 0 13.468 6.025 13.468 13.468C412.956 406.769 367.163 451.466 308.702 451.466z"
            android:fillColor="@android:color/holo_orange_dark" />
        <path
            android:pathData="M283.714 567.419c-156.403 0 -283.642 -127.275 -283.642 -283.714C0.072 127.275 127.311 0 283.714 0c156.394 0 283.633 127.275 283.633 283.705C567.347 440.143 440.108 567.419 283.714 567.419zM283.714 26.946c-141.552 0 -256.705 115.181 -256.705 256.759c0 141.588 115.154 256.768 256.705 256.768c141.543 0 256.696 -115.181 256.696 -256.768C540.41 142.126 425.257 26.946 283.714 26.946z"
            android:fillColor="@android:color/holo_orange_dark" />
    </vector>