I have created a button with the code below, mybutton.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://ift.tt/nIICcg"
android:padding="10dp"
android:shape="rectangle" >
<solid android:color="#97ce68" />
<stroke android:width="1dip" />
<corners
android:bottomLeftRadius="6dp"
android:bottomRightRadius="6dp"
android:topLeftRadius="6dp"
android:topRightRadius="6dp" />
</shape>
I want to add a press effect for that button so I make the following code effect_button.xml :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://ift.tt/nIICcg">
<item android:drawable="@drawable/img1" android:state_pressed="false" android:state_selected="false"/>
<item android:drawable="@drawable/img2" android:state_pressed="true"/>
so how can I add the second xml file(effect_button.xml) to make it the background if I have already use this method with the first file in the stage of creation of the button(mybutton.xml):
Button myButton = new Button(this);
myButton.setBackgroundDrawable(getResources().
getDrawable(R.drawable.
mybutton));
No comments:
Post a Comment