我有带有数据列表的 RecyclerView:
<android.support.v7.widget.RecyclerView
android:id="@+id/categoriesList"
android:layout_width="368dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:background="?android:selectableItemBackground"/>
当我点击此列表中的任何项目时,我会等待按下效果。我没有点击处理程序,但在标准 ListView 中,对元素的任何点击都是可见的。而且我看起来没什么 react
我需要下一个:
最佳答案
您需要将这些行添加到单行布局而不是 recyclerview 标签。
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:background="?android:selectableItemBackground"
关于android - 在 android 中对 RecyclerView 的项目启用按下效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47344795/