Adding ripple effect to already custom button

Usman Noor picture Usman Noor · Mar 15, 2017 · Viewed 8.6k times · Source

I'm trying to add ripple effect to a custom button. But the only solution I found is adding a background which I have already done for achieving rounded corners for that button. Now I want to add the ripple effect. This is how my button tag looks so far:

<Button
    android:text="PLAY"
    android:id="@+id/button"
    android:textSize="20dp"
    android:layout_width="75dp"
    android:layout_height="75dp"
    android:background="@drawable/roundedbutton"
    android:onClick="gotomainpage"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="200dp" />

Answer

Hamid Goodarzi picture Hamid Goodarzi · Mar 15, 2017

use this code in your button

android:foreground="?attr/selectableItemBackground"