Dinesh S
Dinesh S

Reputation: 139

how to give 20 degree angle in gradient?

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>

Upvotes: 3

Views: 4385

Answers (3)

Nico
Nico

Reputation: 41

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.

Upvotes: 3

Amir Hossein Mirzaei
Amir Hossein Mirzaei

Reputation: 2375

according to the documentation

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

Upvotes: 1

Dinesh Neupane
Dinesh Neupane

Reputation: 402

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.

Upvotes: 0

Related Questions