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.> ~ <