安卓上最新版本的 YouTube 应用程序显示了一个非常不同的涟漪。
那就是当我们将手指从按钮上抬起时,然后在结束波纹时它显示出中风。
如何在android中实现这种类型的涟漪?
通过设置它实际上只是一个波纹背景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>
在您的点击视图中添加以下两个属性。
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"