androiddrawableshapesgeometrylayer-list

How to draw multiple shapes in android drawable one after the other similar to vertical oriented Liner layout


I want to draw following shapes - Line and Circle one after the other using android drawable.Please see the attached screen-shot.

enter image description here


Solution

  • I have find solution shown below. The gap between circle and line is achived using a hack. I just draw a stroke over the circle with white color so that it will look like a gap between the circle and line.

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:width="150dp"
        android:height="10dp"
        android:gravity="center">
        <rotate android:fromDegrees="90">
            <shape android:shape="line">
                <stroke
                    android:width="2dp"
                    android:color="@color/c_green_text" />
            </shape>
        </rotate>
    </item>
    <item
        android:width="20dp"
        android:height="20dp"
        android:gravity="center">
        <shape android:shape="oval">
            <stroke
                android:width="3dp"
                android:color="@color/c_white" />
            <solid android:color="@color/c_green_text" />
        </shape>
    </item>
    </layer-list>