Method 1
<Button android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" android:text="Click Me" />
Method 2
res/drawable/ripple_effect.xml
<?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:color="#f816a463" tools:targetApi="lollipop"> <item android:id="@android:id/mask"> <shape android:shape="rectangle"> <solid android:color="#f816a463" /> </shape> </item> </ripple>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#fff" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="16dp" android:text="Click the below buttons to see ripple effect" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/ripple_effect" android:padding="16dp" android:text="Click Me" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="16dp" android:background="@drawable/ripple_effect" android:padding="16dp" android:text="Click Me" /> </LinearLayout>
References
http://www.viralandroid.com/2015/09/how-to-add-ripple-effect-to-android-button.html