Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android oval shape 2 colors

I have a linear layout view whose background I have set to oval shape solid color. So far I have the background as circle. Now I want to achieve same i.e using shape drawable to get a circle with 2 colors. Please see attached.

enter image description here

like image 450
Ranveer Bedaysee Avatar asked Nov 15 '25 09:11

Ranveer Bedaysee


2 Answers

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

    <gradient
        android:centerX="-1"
        android:type="sweep"
        android:startColor="color1"
        android:endColor="color2"
        />

</shape>
like image 163
Audo Avatar answered Nov 17 '25 10:11

Audo


create shape.xml in your drawable folder shape.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<gradient android:startColor="#0000FF" android:endColor="#00FF00"
android:angle="270"/>
</shape>
like image 37
Damini Mehra Avatar answered Nov 17 '25 08:11

Damini Mehra



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!