The demand is when I press the button, the Change button color, so that users feel that they pressed the button, when the release, change back to the original color.
Normal Time:
When pressed:
Some people say, the direct monitor button presses the event to be extremely good, actually this can achieve the same effect, but has a shortcoming, for example many buttons all need this kind of effect, that your same code must repeat many times. So, it's still going to be universal.
First, create a new folder drawable under the Res folder, which is not a resolution:
Create an XML file below: Login_button_selector.xml
Copy Code code as follows:
<selector xmlns:android= "Http://schemas.android.com/apk/res/android" >
<item android:drawable= "@drawable/clr_normal" android:state_pressed= "false"/>
<item android:drawable= "@drawable/clr_pressed" android:state_pressed= "true"/>
</selector>
Then add the following in the String.xml file in the value folder:
Copy Code code as follows:
<drawable name= "Clr_normal" > #ff6501 </drawable>
<drawable name= "clr_pressed" > #a44100 </drawable>
Finally, add the button:
Copy Code code as follows:
<button
android:layout_margintop= "15DP"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
android:text= "@string/loginsubmit"
Android:id= "@+id/login"
Android:textcolor= "@android: Color/white"
android:background= "@drawable/login_button_selector"
/>