简体   繁体   中英

Android multi shape drawable

Hi I'm trying to make a drawable which looks like a small vertical line with a circle attached to the bottom of it. I am trying to figure out if creating such a shape in a single xml file is possible (I know I could probably place two shapes on top of each other but I'm trying to avoid doing that)

Here's what I have so far:

<?xml version="1.0" encoding="utf-8"?>
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/line">
<shape
    android:shape="line"
    >
    <stroke
        android:width="2dp"
        android:color="#000000" />
    <size android:height="12dp"/>

</shape>

    </item>
    <item
        android:top="5px"
        android:id="@+id/circle">
    <shape
        android:shape="oval"
        android:useLevel="false"
        android:innerRadius="5dp"
        android:thickness="2dp"
        >

        <solid
            android:color="@color/silver_status"
            ></solid>
        <stroke
            android:color="@color/silver_status"
            android:width="1dp"
            />
    </shape>
    </item>
</layer-list>

This layers the two images on top of each other (I think) but what I really want is for them to be on top of each other

Anyone know if this is possible/how it can be done?

I ended up solving this simply by using the individual shapes within a linear layout to achieve the affect. Not exactly what I wanted but definitely does the job just fine.

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