1

In my application I want to apply gradient to Button. I have written following code and the result is perfect.

<?xml version="1.0" encoding="utf-8"?>

<layer-list 
xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape>
            <padding 
                android:left="1dp"
                android:top="1dp"
                android:right="1dp"
                android:bottom="1dp"/>

            <solid 
            android:color="#FF000000"/>

        </shape>
    </item>

    <item>
        <shape>
            <padding 
            android:left="5dp"
            android:top="5dp"
            android:right="5dp"
            android:bottom="5dp"/>

            <gradient 
            android:startColor="#FFB0B0B0"
            android:centerColor="#FFFFFFFF"
            android:endColor="#FFB0B0B0"
            android:angle="315"/>

            <corners 
            android:radius="3dp"/>
        </shape>
    </item>


</layer-list>

But my problem is, when I click on this button I have no effect or animation such as original one. Therefor, I want to add some effect on it that when user clicks on it the button becomes bigger and when released the key, the button comeback to its situation.

guide me please. thanks :)

Hesam
  • 52,260
  • 74
  • 224
  • 365

1 Answers1

0

This is for only background of button but you have not specified anything for different events like click, hover, etc.

For that you have to create another set of styles and set them in selector as in my previous answer and make that selector as background of your button

Community
  • 1
  • 1
ingsaurabh
  • 15,249
  • 7
  • 52
  • 81
  • Thanks dear ingsaurabh, I saw this wary before but I don't want to use image. I want, if its possible, shift it down when pressed and sift it back when released. is it possible? – Hesam Oct 05 '11 at 05:50
  • yes you ave to create different styles for different states and then as given on link put those styles instead of bitmaps and its all done – ingsaurabh Oct 05 '11 at 06:09