gpt4 book ai didi

android - 在 android 中对 RecyclerView 的项目启用按下效果

转载 作者:行者123 更新时间:2023-11-30 00:15:41 28 4
gpt4 key购买 nike

我有带有数据列表的 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

我需要下一个:

enter image description here

最佳答案

您需要将这些行添加到单行布局而不是 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com