Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shape with outer stroke only

<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="oval"
       xmlns:android="http://schemas.android.com/apk/res/android"
    >
    <solid android:color="#ffffff"/>

    <stroke android:width="30dp"
            android:color="#51000000"
        />
</shape>

It gives a "half-inner-half-outer" stroke. What I need is outer semitransparent stroke only. Can it be done?

What I have is What I have

What I need is What I need

Thanks

like image 445
MobileX Avatar asked Mar 17 '26 23:03

MobileX


2 Answers

you can check this shape created using layer list with it's items.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item >
        <shape android:shape="oval" >
            <solid android:color="#fff" />
        </shape>
    </item>

    <item >
        <shape android:shape="oval">
            <solid android:color="@android:color/transparent" />
            <stroke
                android:width="50dp"
                android:color="#30000000" />
        </shape>
    </item>

</layer-list>
like image 62
santosh kumar Avatar answered Mar 20 '26 11:03

santosh kumar


I've found no way to do that other than the following:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item >
        <shape android:shape="oval">
            <solid android:color="@android:color/transparent" />
            <stroke
                android:width="@dimen/stroke_width"
                android:color="#33000000" />
        </shape>
    </item>

    <item >
        <shape android:shape="oval" >
            <solid android:color="#fff" />
            <stroke
                android:width="@dimen/stroke_width"
                android:color="@android:color/transparent">
            </stroke>
        </shape>
    </item>
</layer-list>
like image 35
MobileX Avatar answered Mar 20 '26 11:03

MobileX



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!