jitain sharma
jitain sharma

Reputation: 604

How to create the custom drawable diagonal gradient

I want to create the background gradient shown in attached image.

Currently I am using this xml, which is not giving the required effects:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:angle="225"
        android:endColor="#FF5C1E"
        android:startColor="#A300F3"
        android:type="linear"
        android:useLevel="false" />
</shape>

Please help me out here. enter image description here

Upvotes: 1

Views: 606

Answers (1)

milad salimi
milad salimi

Reputation: 1660

You should use radial type of gradient for using this you should set coordinates X and Y as centerX and centerY and finally for radius use this gradientRadius field.

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:centerX="0.9"
        android:centerY="0.1"
        android:endColor="#FF5C1E"
        android:gradientRadius="1700"
        android:startColor="#A300F3"
        android:type="radial" />
</shape>

Upvotes: 1

Related Questions