我試圖在RecyclerView上實現漣漪效應。這是我的佈局吧:對RecyclerView不起作用的輕敲效果燈杆
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card"
android:layout_marginTop="7dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="5dp"
android:clickable="true"
card_view:cardElevation="5dp"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
//some properties />
<TextView
//some properties />
<TextView
//some properties />
</LinearLayout>
</android.support.v7.widget.CardView>
爲了實施的onclick監聽我基本上遵循本教程在這裏:http://sapandiwakar.in/recycler-view-item-click-handler/
的問題是,產生的連鎖反應,產生得益於行:
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
不能在光線(就是快速)按下。當我快速點擊屏幕時,會觸發點擊監聽器。這意味着觸摸事件已被檢測到,但沒有顯示出連鎖反應。如果我想看到漣漪效應,我必須在釋放之前將屏幕上的壓力保持一段時間。
有沒有一種方法可以糾正這種行爲,並且即使對於快速按下也會產生連鎖反應?
使用'selectableItemBackgroundBorderless'。我認爲棉花糖改變了'selectableItemBackground'的行爲,所以它只顯示更長的水龍頭的波紋。 –