Tôi muốn các mục trong RecyclerView có phản hồi chạm hoặc gợn sóng khi được nhấn, nhưng chúng dường như không hoạt động và tôi nghĩ đó là do hộp kiểm.RecyclerView mục không hiển thị gợn sóng/phản hồi cảm ứng khi mục có hộp kiểm
Ripple chỉ hiển thị khi nhấn và giữ, nhưng một lần nhấn đơn giản sẽ không hiển thị.
Có thể ai đó giúp tôi khắc phục sự cố? Cảm ơn trước.
PD: Tôi đang sử dụng ListView và bố cục bố cục mục là LinearLayout. Những gợn sóng đang hoạt động tốt. Sau khi chuyển sang RecyclerView, các mục gợn sóng không hoạt động. Tôi đã thử với LinearLayout một lần nữa, nhưng vẫn không hoạt động.
Dưới đây là file layout
<?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>
Thêm android: descendantFocusability = "blocksDescendants" vào phần tử gốc của mục của bạn. –
@GabrieleMariotti đã làm. Vẫn không làm việc. Đã cập nhật tệp bố cục. –
Tôi không hoàn toàn chắc chắn, nhưng điều này có thể xảy ra vì các chế độ xem trong nhóm xem bao gồm hiệu ứng gợn sóng của bạn. Vì vậy, nó ở đó, nhưng bạn không thể nhìn thấy nó. Vì vậy, tôi đã kết thúc trong việc thêm một cái nhìn đơn giản thêm (với chiều rộng và chiều cao match_parent) đặc biệt cho gợn. Bạn có thể muốn thử. –