1. Implementation results
Button normal effect
Button-click Validity Period
2. Now the pivot effect button
The button for implementing the perspective effect focuses on two points:
1. Button background implementation
2. Button font color implementation
2.1 button background implementation
The Perspective color mainly adds the alpha value to the background color value.
Button perspective Implementation
<? Xml version = "1.0" encoding = "UTF-8"?>
<Shape
Xmlns: android = "http://schemas.android.com/apk/res/android"
Android: shape = "rectangle"
Android: useLevel = "false">
<Padding
Android: left = "10px"
Android: top = "5px"
Android: bottom = "5px"
Android: right = "10px"
/>
<Corners
Android: radius = "10px"
/>
<Solid
Android: color = "#7fE6E6E6"
> </Solid>
</Shape>
Button click background implementation
<? Xml version = "1.0" encoding = "UTF-8"?>
<Shape
Xmlns: android = "http://schemas.android.com/apk/res/android"
Android: shape = "rectangle"
Android: useLevel = "false">
<Padding
Android: left = "10px"
Android: top = "5px"
Android: bottom = "5px"
Android: right = "10px"/>
<Corners
Android: radius = "10px"/>
<Solid
Android: color = "# 0040FF"> </solid>
</Shape>
2.2 button font color implementation
<? Xml version = "1.0" encoding = "UTF-8"?>
<Selector xmlns: android = "http://schemas.android.com/apk/res/android">
<Item android: state_window_focused = "false"
Android: color = "@ color/black"
> </Item>
<Item
Android: state_pressed = "true"
Android: color = "@ color/white"
> </Item>
<Item android: color = "@ color/black"> </item>
</Selector>
From XU wenbing's IT blog