Android custom control skin

Source: Internet
Author: User

Android custom control skin
Android custom control skin

For the built-in Android control, its appearance can only be quite satisfactory. In the Android Application we usually see, a simple button is very beautiful, even when many buttons are pressed, the appearance changes and the user experience is very good. In this example, the operation method of the Android custom control property is involved. The following operation takes the skin of the Custom button as an example.

1. we want to customize the appearance status to be implemented, which can be an image or a custom xml. This is the color xml that we directly customize for different States and create colors under the values directory. the Code is as follows:

Colors. xml


  
      
   
    #3300ffff
       
   
    #33ffff00
   
  

The name in the file can be customized according to the project requirements. The value is in the argb format.

2. We need to set different states of the button to be implemented. Create a btn_bg.xml file in the drawable directory. Select "selector" for the type. The Code is as follows:

Btn_bg.xml


  
      
       
   
  

Android: state_pressed = "" defines whether the control is pressed and its value is boolean. For similar properties, you can try it yourself. android: drawable = "" defines the appearance of the control when it is in the corresponding state.

3. Now we can apply the defined state to the layout file. The Code is as follows:

Activity_main.xml


      
   
  

After completing the preceding steps, you can run and debug the application. This is just a simple example.> ~ <

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.