我希望RecyclerView中的项在被按下时能够有触摸反馈或波纹效果,但它们似乎不起作用,我认为这是由于复选框引起的。
只有在长按时才会显示波纹,而简单的按下则不会显示。
请问有人可以帮助我解决这个问题吗?提前感谢。
附注:我之前使用的是ListView,而且项布局的父布局是LinearLayout。波纹效果正常工作。但是转移到RecyclerView后,项的波纹效果就不起作用了。我尝试重新使用LinearLayout,但仍然不起作用。
以下是布局文件。
只有在长按时才会显示波纹,而简单的按下则不会显示。
请问有人可以帮助我解决这个问题吗?提前感谢。
附注:我之前使用的是ListView,而且项布局的父布局是LinearLayout。波纹效果正常工作。但是转移到RecyclerView后,项的波纹效果就不起作用了。我尝试重新使用LinearLayout,但仍然不起作用。
以下是布局文件。
<?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>