3

I want to give 20 degree angle in the gradient what i have to do to achieve that?This is my xml code.

<?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <gradient android:startColor="#eeeeee"
            android:endColor="#ffffff"
            android:angle="0" />
    </shape>
Dinesh S
  • 139
  • 2
  • 13
  • may be 20 gradient is not supporting in gradient. i also tried it but didn't get success for same. you can refer https://stackoverflow.com/a/12155542/3713967 for more details – Sameer Donga Jul 06 '18 at 06:05
  • @Dinesh 20 degree is not supported – Dilip Jul 06 '18 at 06:26

3 Answers3

3

It seems like only multiples of 45 are accepted as an angle.

From doc: https://developer.android.com/guide/topics/resources/drawable-resource#Shape

android:angle Integer. The angle for the gradient, in degrees. 0 is left to right, 90 is bottom to top. It must be a multiple of 45. Default is 0.

To achieve the same effect, you could perhaps try to overlay a horizontal gradient with a partially transparent vertical gradient.

Nico
  • 41
  • 6
1

according to the documentation

Angle of the gradient, used only with linear gradient. Must be a multiple of 45 in the range [0, 315].

Amir Hossein Mirzaei
  • 2,325
  • 1
  • 9
  • 17
0
android:angle

According to Official Documentation you can only use the multiples of 45 as gradient angle (in degrees). 0 is left to right, 90 is bottom to top. The default value is 0.

Dinesh Neupane
  • 382
  • 10
  • 19