0

I want to have a gradient like below image.

image

I have created this shape but even after trying so many times I couldn't achieve such type of gradient. Any help would be highly appreciated.

This is the work I've done:

<shape android:shape="rectangle">
    <gradient
        android:startColor="@color/red"
        android:centerColor="@color/light_red"
        android:endColor="@color/light_red"
        android:angle="90"
        />
    <corners
        android:radius="20dp"
        />
</shape>
Vishnu
  • 11,614
  • 6
  • 51
  • 90
Zeeshan Ali
  • 2,211
  • 4
  • 18
  • 25

2 Answers2

0

This link similar to your need Multi-gradient shapes

or

use this online tool http://angrytools.com/gradient/

Community
  • 1
  • 1
Rajesh
  • 2,618
  • 19
  • 25
0

You can use a sweep gradient for this! A sweep gradient looks a bit like a cone, but by offsetting it waaaaay to the left (via centerX), you can achieve the effect with a single gradient.

Here's how it looks (ignore the shape): sweep gradient

Here's the XML:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:startColor="@android:color/red"
        android:endColor="@android:color/holo_orange_dark"
        android:centerX="-99"
        android:type="sweep" />
    <corners android:radius="20dp" />
</shape>
Jake Lee
  • 7,549
  • 8
  • 45
  • 86