简体   繁体   中英

Making android custom drawable

可绘制

How can one create such a drawable that will be matching height of given layout ? I know I have to create a some sort of multiple shapes within one drawable but I am kinda lost in this.

Try layer-list of 2 oval shapes and a line. Then set as the background of your view. I'm not sure if it works.

You can also use 9 patch: read this

It should work with xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:paddingTop="4dp">
    <item>
        <rotate android:fromDegrees="90" android:gravity="center_horizontal" android:toDegrees="90">
            <shape android:shape="line">
                <stroke android:color="#000000" android:width="1dp"/>
            </shape>
        </rotate>
    </item>
    <item android:gravity="center_horizontal|top" android:height="8dp" android:width="8dp">
        <shape android:shape="oval">
            <solid android:color="#000000"/>
        </shape>
    </item>
    <item android:gravity="center_horizontal|bottom" android:height="4dp" android:width="4dp">
        <shape android:shape="oval">
            <solid android:color="#000000"/>
        </shape>
    </item>
</layer-list>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM