2

安卓上最新版本的 YouTube 应用程序显示了一个非常不同的涟漪。

那就是当我们将手指从按钮上抬起时,然后在结束波纹时它显示出中风。

如何在android中实现这种类型的涟漪?

当我们抬起手指时,波纹的末端有一个笔触。

4

2 回答 2

0

通过设置它实际上只是一个波纹背景android:background="?selectableItemBackground"

在 Youtube 按钮示例中,

<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>
于 2021-06-22T03:54:49.507 回答
0

在您的点击视图中添加以下两个属性。

android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
于 2021-06-22T04:00:25.930 回答