Change the color when the Android button is pressed.

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.