標籤:
1. 定義一個普通圓角背景的xml;
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.水波紋效果的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 在布局xml中使用它
<Button android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/ripple_bg" android:text="@string/hello_world" />
這個只能在5.0版本之上的手機中使用,5.0之下的只能自己繪製,聽說
而大家想相容低系統版本的話,就需要建立v21(即Android5.0)的Resource Directory.
還沒做出基本的低版本解決方案來
android 5.0 水波紋 實現