带有LiveData的波纹效果/ click动画

我在LinearLayout中有项目。单击时,项目会打开其他活动。当我单击列表项时,出现波纹效果。但是列表项是LiveData,涟漪效应不会出现在该项目上。由于波纹效应需要很少的时间出现并且LiveData很快。我能做什么?

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:foreground="@drawable/clicked">

clicked.xml:

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="@color/colorPrimaryDark">

    <item
        android:id="@android:id/mask"
        android:drawable="@color/colorPrimaryDark" />
</ripple>
xj0605 回答:带有LiveData的波纹效果/ click动画

我解决了这个问题。我用这些代码代替涟漪。

waitForReadyRead(1)

android:background="@android:drawable/list_selector_background"

on_press_animation.xml:

android:background="@drawable/on_press_animation"

    

<?xml version="1.0" encoding="utf-8"?>

本文链接:https://www.f2er.com/3022023.html

大家都在问