Android Fill Vector Image Transparent Section With Color Using LayerDrawable

September 30, 2019

Material Vector Image ic_check_circle is a checked mark in a circle, where the checked mark is transparent. I want to fill the checked mark with white color, while outside the circle remain transparent.

The solution is to use LayerDrawable and put a white oval share behind ic_check_circle.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item>
        <shape android:shape="oval">
            <solid android:color="@android:color/white"/>
            <stroke android:color="@android:color/transparent"
                android:width="5dp"/>
        </shape>
    </item>

    <item
        android:gravity="center"
        android:drawable="@drawable/ic_check_circle_blue_24dp"
        />
</layer-list>
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.