在我的应用程序中,我想要创建一个覆盖整个视图的涟漪效果。由于它没有正常工作,我创建了一个最小的示例应用程序,并在那里尝试了一下,但是没有成功。
我的布局看起来像这样:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent" android:padding="16dp">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ripple"
android:onClick="onViewClicked" />
</LinearLayout>
我的drawable定义如下:
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#1E88E5"
android:radius="0dp">
<item
android:id="@android:id/mask"
android:drawable="@android:color/white" />
</ripple>
这里有一个视频,展示了目前的表现。我希望圆圈(我认为它在官方上被称为热点)从中间开始增大,直到填满整个View
。我说的不是波纹的半径,在这里有意设置为0dp。您有什么想法可以实现这一点吗?
编辑:最终我想实现像这样的效果。对于不想阅读所有答案的人:我成功地实现了它,并为此创建了一个存储库。请随意在您的项目中使用它并向我发送拉取请求。