Ideas:
Add one or more layers to the custom shape and stagger to show the shadow effect. To add three-dimensional sense, when the button is pressed, only one layer is set. we can control the direction and size of shadows by using top, bottom, right and left four parameters.
Relationship Diagram
The following two shadow effects are customized:
Res/drawable-hdpi/shadow1.xml
<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android "> <item android:state_pressed=" true "> <layer-list> <item android:le ft= "4DP" android:top= "4DP" ><shape> <solid android:color= "#ff58bb52"/> <corners android:radius= "30dip"/> </shape></item> </layer-list> </i Tem> <item> <layer-list> <!--first Floor--<item android:left= "4DP" and roid:top= "4DP" ><shape> <solid android:color= "#66000000"/> <corner S android:radius= "30dip"/> <!--stroke--<stroke android:width= "1DP" Android Oid:color= "#ffffffff"/> </shape></item> <!--second Floor--<item a Ndroid:bottom= "4DP" android:right= "4DP"><shape> <solid android:color= "#ff58bb52"/> <corners Android:radi us= "30dip"/> <!--strokes--<stroke android:width= "1DP" android:color= "#ff Ffffff "/> </shape></item> </layer-list></item></selector>
/testaa/res/drawable-hdpi/shadow2.xml
<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android > <!--click <item android:state_pressed= "true" > <layer-list> < Item android:left= "4DP" android:top= "4DP" > <shape> <solid android:color= "#ff58bb52"/> <corners android:radius= "3DP"/> </shape> </item> </layer-list></item& Gt <!--Normal--<item> <layer-list> <!--first Floor--<item android:left= "2DP" android:top= "2DP" > <shape> <solid Android:color= "#66000000"/> <corners Android:radiu s= "3DP"/> </shape> </item> <!--second Floor--<item android:bottom= "4DP "Android:right=" 4DP > <shape> <solid Android:color= "#ff58bb52"/> <corners android:radius= "3DP"/> </shape> </item> <!--third tier--<item Android : bottom= "6DP" android:right= "6DP" > <shape> <solid Android:color= "#ffcccccc"/> <corners android:radius= "3DP" /> </shape> </item> </layer-list> </item></selector>
: