add the xml file to your name res / drawable folder it button_selector.xml add also two drawable for the pressed state, and the other for the unset or normal state. Finally, add these two xml file button switches and everything should work! don't forget to set @ drawable / bytton_selector.xml as the background of your button in the main.xml file.
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/btn_pressed" android:state_pressed="true"/> <item android:drawable="@drawable/btn_unpressed"/> </selector>
K_Anas
source share