私はRecyclerViewにリップル効果を実装しようとしました。ここに私のレイアウトは、それのためだ:私は基本的にここにこのチュートリアルに従っonclickのリスナーを実現するために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>
:
: http://sapandiwakar.in/recycler-view-item-click-handler/問題は波及効果が、ラインのおかげで生成していることです
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
は軽い(つまり、すばやく)印刷機では機能しません。画面をすばやくタップすると、クリックリスナーがトリガーされます。タッチイベントが検出されたことを意味しますが、リップル効果は表示されません。波及効果を見たい場合は、解放する前に画面上の圧力をもう少し長く維持する必要があります。
この動作を修正し、迅速なプレスでも波紋効果を表示する方法はありますか?
'selectableItemBackgroundBorderless'を使用してください。私はMarshmallowが 'selectableItemBackground'の振る舞いを変更したので、より長いタップだけのリップルを表示すると思います。 –