Nirav Ranpara
Nirav Ranpara

Reputation: 13785

Gradient effect in button

I have try below xml code but I do not get output as in image.

<item  >
    <shape>
        <gradient
           android:startColor= "#AE845c"
           android:endColor="#935Fc0"

             />


    </shape>
</item>

I want like this .

enter image description here

Upvotes: 1

Views: 320

Answers (3)

Nipun Gogia
Nipun Gogia

Reputation: 1856

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
     android:shape="rectangle">
     <stroke android:width="2dp" android:color="#FFFFFFFF" />
       <gradient android:startColor="#FFFFFFFF" android:endColor="#FFFFFFFF"
            android:angle="225"/> 

    <corners android:bottomRightRadius="5dp" android:bottomLeftRadius="5dp"
     android:topLeftRadius="5dp" android:topRightRadius="5dp"/>
</shape> 

you can try this...

Upvotes: 0

Android Killer
Android Killer

Reputation: 18499

try to add angle

<item  >
    <shape>
        <gradient
           android:angle="90"
           android:startColor= "#bc9b78"
           android:endColor="#7c4727"

             />


    </shape>
</item>

if it's not working please put code where you are using this.

Upvotes: 2

Chirag
Chirag

Reputation: 56925

Use android type and angle for gradient. Change angle value from 0 to 360 as per your requirement.

android:type="linear"
android:angle="0"

Upvotes: 2

Related Questions