Search code examples
androidxmlandroid-drawable

Is this image achievable through android drawable xml?


I'm trying to achieve the below image through Android xml

enter image description here

Right now I could just achieve this with help of some SOF q&a

enter image description here

Below are the code to achieve the above result

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item>
    <rotate
        android:fromDegrees="45"
        android:toDegrees="45"
        android:pivotX="87%"
        android:pivotY="140%">
        <shape android:shape="rectangle">
            <solid android:color="@color/lime_green_32CD32"/>
        </shape>
    </rotate>
</item>

Solution

  • Using below code, you can get something close to enter image description here

    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
                <item
                    android:width="35dp"
                    android:height="35dp"
                    android:top="7dp">
                    <rotate
                        android:fromDegrees="45"
                        android:pivotX="87%"
                        android:pivotY="140%"
                        android:toDegrees="45">
                        <shape android:shape="rectangle">
                            <solid android:color="@color/white" />
                        </shape>
                    </rotate>
                </item>
                <item
                    android:width="150dp"
                    android:height="50dp"
                    android:left="44.5dp">
                    <shape android:shape="rectangle">
                        <solid android:color="@color/white" />
                    </shape>
                </item>
                <item
                    android:width="10dp"
                    android:height="10dp"
                    android:left="35dp"
                    android:top="20dp">
                    <shape android:shape="oval">
                        <solid android:color="@color/white" />
                    </shape>
                </item>
            </layer-list>
        </item>
        <item android:top="2dp" android:bottom="2dp" android:right="2dp" android:left="2dp">
            <layer-list>
                <item
                    android:width="33dp"
                    android:height="33dp"
                    android:left="2dp"
                    android:top="6dp">
                    <rotate
                        android:fromDegrees="45"
                        android:pivotX="87%"
                        android:pivotY="140%"
                        android:toDegrees="45">
                        <shape android:shape="rectangle">
                            <solid android:color="@color/green" />
                        </shape>
                    </rotate>
                </item>
                <item
                    android:width="145dp"
                    android:height="46dp"
                    android:left="44.5dp">
                    <shape android:shape="rectangle">
                        <solid android:color="@color/green" />
                    </shape>
                </item>
                <item
                    android:width="10dp"
                    android:height="10dp"
                    android:left="35dp"
                    android:top="20dp">
                    <shape android:shape="oval">
                        <solid android:color="@color/white" />
                    </shape>
                </item>
            </layer-list>
        </item>
    </layer-list>