1. Define an XML with a normal rounded background;
Rounded_corners.xml
<?xml version= "1.0" encoding= "Utf-8"? ><shape xmlns:android= "Http://schemas.android.com/apk/res/android" android:shape= "Rectangle" > <solid android:color= "#FFFFFF"/> <corners android: radius= "4DP"/></shape>
2. The water ripple effect of the XML ripple_bg.xml:
<?xml version= "1.0" encoding= "Utf-8"? ><ripple xmlns:android= "Http://schemas.android.com/apk/res/android" Android:color= "#FF21272B" > <item> <shape android:shape= "Rectangle" > <solid android:color= "#FFFFFF"/> <corners android:radius= "4DP"/> </shape> </ item> <item android:drawable= "@drawable/rounded_corners"/></ripple>
3 Use it in the layout XML
< Button Android:layout_width = "Match_parent" android:layout_height= "Wrap_content" android:background= "@drawable/ RIPPLE_BG " android:text=" @string/hello_world "/>
This can only be used on the 5.0 version of the mobile phone, under 5.0 can only draw their own, heard
If you want to be compatible with a low-system version, you need to create a new v21 (i.e. Android5.0) resource Directory.
Haven't yet made a basic low-version solution to
Android 5.0 Water Ripple Implementation