How to show YouTube like ripple effect in android?

226 Views Asked by At

Latest versions of YouTube app on android shows a ripple which is pretty different.

That is when we lift our finger from button, then at the time of ending ripple it shows stroke.

How to achieve this type of ripple in android?

When we lift finger, there is stroke at the end of ripple.

2

There are 2 best solutions below

2
Teo On

It is actually just a ripple background by setting android:background="?selectableItemBackground"

In Youtube button example,

<RelativeLayout
    android:id="@+id/rl_chat_search"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?selectableItemBackground"  <-- ripple effect
    android:layout_margin="10dp">

    <ImageView
        android:src="@drawable/ic_download"

    />

    <TextView
        android:text="Download"
      />
</RelativeLayout>
1
Dharmender Manral On

Add below two attribute in your click view.

android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"