0

I have some code for setting the background for my buttons, but when I run the code, I don't see the effect of click in my buttons! Below, I show you my xml file for the background. Thanks!

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:left="5dp"
        android:right="5dp"
        android:top="5dp"
        android:bottom="5dp"
        >
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle">
            <solid android:color="#ffe49713">
            </solid>
        </shape>
    </item>
</layer-list>
jbaums
  • 27,115
  • 5
  • 79
  • 119

1 Answers1

0

Try adding this to backgorund of your button.Change the colors according to your req

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_focused="true" android:state_pressed="false" android:color="@android:color/holo_red_dark"/>
    <item android:state_focused="true" android:state_pressed="true" android:color="#ffffff"/>
    <item android:state_focused="false" android:state_pressed="true" android:color="#ffffff"/>
    <item android:color="@android:color/holo_red_dark"/>

</selector>
Anirudh Sharma
  • 7,968
  • 13
  • 40
  • 42