RecyclerViewのアイテムを押したときにタッチフィードバックまたはリップルが表示されますが、機能していないように見えます。RecyclerViewアイテムにチェックボックスが表示されているときに波紋/タッチのフィードバックが表示されない
リップルは長い押しでのみ表示されますが、簡単なプレスでは表示されません。
誰かが私にそれを修正するのを手伝ってもらえますか?前もって感謝します。
PD:ListViewを使用していて、アイテムレイアウトの親がLinearLayoutでした。波紋はうまくいきました。 RecyclerViewに移動した後、項目の波紋は機能しません。私はLinearLayoutをもう一度試しましたが、まだ動作していません。
は、ここであなたがandroid:background="?android:attr/selectableItemBackground"
使用レイアウトファイル
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/requestCard"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:descendantFocusability="blocksDescendants"
android:orientation="horizontal">
<ImageView
android:id="@+id/imgIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:maxHeight="64dp"
android:maxWidth="64dp"
android:padding="@dimen/lists_padding"
android:src="@drawable/ic_launcher"
tools:ignore="ContentDescription"/>
<TextView
android:id="@+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/imgIcon"
android:layout_toRightOf="@+id/imgIcon"
android:ellipsize="end"
android:maxLength="@integer/request_text_length"
android:maxLines="1"
android:padding="@dimen/lists_padding"
android:textSize="@dimen/abc_text_size_large_material"
tools:text="App Name"/>
<CheckBox
android:id="@+id/chkSelected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:clickable="false"
android:padding="@dimen/lists_padding"/>
</RelativeLayout>
アンドロイドを追加:descendantFocusability = "blocksDescendants"アイテムのルート要素。 –
@GabrieleMariottiは既にしました。まだ動かない。更新されたレイアウトファイル。 –
私は確信していませんが、ビューグループのビューが波紋効果をカバーするため、これが起こる可能性があります。だからそこにはありますが、見ることはできません。リップル専用の特別なビュー(幅と高さはmatch_parent)を追加することになりました。試してみてください。 –