1. Under the drawable file, create a new seletor, as the background of the button, here I use the shape of two rounded corners
<?XML version= "1.0" encoding= "Utf-8"?><selectorxmlns:android= "Http://schemas.android.com/apk/res/android"><Itemandroid:drawable= "@drawable/shape_btn_cycle_normal"/> <Itemandroid:state_pressed= "true"android:drawable= "@drawable/shape_btn_cycle_press"/></selector>
Shape_btn_cycle_normal
<?XML version= "1.0" encoding= "Utf-8"?><Shapexmlns:android= "Http://schemas.android.com/apk/res/android"Android:shape= "Rectangle"> <CornersAndroid:bottomleftradius= "20DP"Android:bottomrightradius= "20DP"Android:topleftradius= "20DP"Android:toprightradius= "20DP"/> <SolidAndroid:color= "@color/colorwhite"/></Shape>
Shape_btn_cycle_press
<?XML version= "1.0" encoding= "Utf-8"?><Shapexmlns:android= "Http://schemas.android.com/apk/res/android"Android:shape= "Rectangle"> <CornersAndroid:bottomleftradius= "20DP"Android:bottomrightradius= "20DP"Android:topleftradius= "20DP"Android:toprightradius= "20DP"/> <SolidAndroid:color= "@color/colorgray"/></Shape>
2. Under the DRAWABLE-V21, the new ripple with selector name, as above, my selector is SELECTOR_BTN_CYCLE_BG, here drawable-v21 under the new Selector_btn_cycle_ Bg.xml
<? xml version= "1.0" encoding= "Utf-8" ?> < ripple xmlns:android = "Http://schemas.android.com/apk/res/android" Android:color = "@color/colorgray" > //color of the selected water ripple < item android:drawable = "@drawable/shape_btn_cycle_normal" /> //unselected background State </ ripple >
Android Water Ripple Effect implementation