Recently tried to play Android development, do a gadget, always feel the default button style is too bad, see the Internet several iphone screenshots, feel the button a little bit feel, just want to copy a come over ... There is no technical content, just a bad memory, recorded.
The preparation on Photoshop
In a simple way, set the background picture.
First gradient fill Rounded rectangle (radius 4 or so), the beginning and end color of the gradient itself set, but the transition position I tried, about the figure 1 above, in 40% and 60% increased two color, the value of the difference between the end of 1/3 and 2/3.
Make three-dimensional effects and shadows, as shown in 2
Make a border line, as shown in 3
Then tune the two bright and darker (unused iphone does not know the focus and what it looks like when I'm lazy to get a change of tone) button.
Apply To Button
Define a model file in drawable
<?xml version= "1.0" encoding= "Utf-8"?>
<selector
Xmlns:android= "Http://schemas.android.com/apk/res/android" >
<item android:state_pressed= "true" android:drawable= "@drawable/game_button_pressed"/>
<item android:state_focused= "true" android:drawable= "@drawable/game_button_focused"/>
<item android:drawable= "@drawable/game_button_normal"/>
</selector>
Then the button's background points to it, it's over ~ ~
Worm
Later saw a complete use of XML to define a button method, reliable, although the change seems to be a bit monotonous, but can not use the picture is good after all, the first record of the method, have time to try ~
<?xml version= "1.0" encoding= "Utf-8"?>
<selector xmlns:android= "Http://schemas.android.com/apk/res/android" >
<item android:state_pressed= "true" >
<shape>
<gradient android:startcolor= "#0d76e1" android:endcolor= "#0d76e1" android:angle= "270"/>
<stroke android:width= "1dip" android:color= "#f403c9"/>
<corners android:radius= "2DP"/>
<padding android:left= "10DP" android:top= "10DP"
android:right= "10DP" android:bottom= "10DP"/>
</shape>
</item>
<item android:state_focused= "true" >
<shape>
<gradient android:startcolor= "#ffc2b7" android:endcolor= "#ffc2b7" android:angle= "270"/>
<stroke android:width= "1dip" android:color= "#f403c9"/>
<corners android:radius= "2DP"/>
<padding android:left= "10DP" android:top= "10DP"
android:right= "10DP" android:bottom= "10DP"/>
</shape>
</item>
<item>
<shape>
<gradient android:startcolor= "#000000" android:endcolor= "#ffffff" android:angle= "180"/>
<stroke android:width= "1dip" android:color= "#f403c9"/>
<corners android:radius= "5dip"/>
<padding android:left= "10DP" android:top= "10DP"
android:right= "10DP" android:bottom= "10DP"/>
</shape>
</item>
</selector>