Adding Button Selector
to add button selector to the button in the android xlm layout file, create a new xml file named button selector and use the following code :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/manage_atms" android:state_pressed="false" android:state_selected="false"/>
<item android:drawable="@drawable/manage_atms_mouseover" android:state_pressed="true"/>
<item android:drawable="@drawable/manage_atms" android:state_pressed="false" android:state_selected="true"/>
</selector>
In the above code add the images to the item tag for pressed or not pressed button state.
Then add this xml selector file to the background of the button. Example
<Button
android:id="@+id/manage_atms"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="10dp"
android:background="@drawable/manage_atm_button_selector"
android:onClick="onClick" />
Thank you, hope the code helps.
0 Comment(s)