The requirement is that when I press the button, it changes the color of the button so that the user can feel that he has pressed the button. When the button is released, it changes back to the original color.
Normal:
Press:
Some people say that directly listening to button-pressing events is incredible. In fact, this can indeed achieve the same effect, but there is a drawback. For example, many buttons require this effect, then you must repeat the same code many times. Therefore, it is still necessary to use it in general.
First, create a folder named drawable In the res folder, which has no resolution:
Create an xml file: login_button_selector.xml <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + PHByZSBjbGFzcz0 = "brush: java;">
Add the following content to the string. xml file in the value Folder:
#ff6501
#a44100
Add button at last:
OK.