Android how to move drawable XML form relative to other shapes

I want to create a clock type type. This code does what I want, but I feel like I am doing it wrong:

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <size android:width="100dp"
        android:height="100dp"/>
    <item>
        <shape android:shape="oval">
            <size
                android:width="100dp"
                android:height="100dp"/>

            <stroke
                android:width="1.5dp"
                android:color="#FFF" />
        </shape>
    </item>
    <item android:top="25dp" android:left="25dp" android:right="25dp" android:bottom="25dp">
        <shape android:shape="oval">
            <stroke
                android:width="1.5dp"
                android:color="#FFF" />
        </shape>
    </item>
    <item android:top="0dp" android:right="49.25dp" android:left="49.25dp" android:bottom="75dp">
        <shape android:shape="rectangle">

            <solid
                android:color="#0FFF00" />
        </shape>
    </item>
</layer-list>

Green checkmark. It seems to me that I can define using a tag <size>and be able to position more elegantly than defining empty space using the fields around item.

+4
source share

Source: https://habr.com/ru/post/1609729/


All Articles