android - 通过单击 RecyclerView 项对整个父视图产生波纹效果
问题描述
我有一个 CardView,其中包括 RecyclerView。当用户单击 RecyclerView 项目时,我尝试对整个 CardView(或整个 RecyclerView)产生涟漪效应,但涟漪效应仅适用于项目。
<android.support.v7.widget.CardView
android:id="@+id/cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?attr/selectableItemBackground">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent"/>
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
解决方案
将以下属性添加到您的CardView
.
<android.support.v7.widget.CardView
...
android:clickable="true"
android:focusable="true"
android:background="?android:selectableItemBackground"/>
运行您的应用程序。它应该工作。
推荐阅读
- xamarin - 如何在 Xamarin 中实现 SfMap
- php - PHP文件上传 - 重命名文件
- angular - 如果通过制表键聚焦元素,角度材料垫复选框不会突出显示
- angular - NullInjectorError:StaticInjectorError(DynamicTestModule)[HttpClient -> HttpHandler]:StaticInjectorError(平台:核心)[HttpClient ->
- postgresql - 如何选择不存在的列并以数字方式递增到最后一行
- javascript - 插入新文本javascript后如何保持光标位置
- java - 我应该如何使用 Spring Web 应用在浏览器中显示 pdf 文件?
- javascript - Vuejs单文件组件未在页面中呈现
- django - Django通过选择器函数获取FK
- css - 将整数添加到新 SASS 中的颜色的等价物是什么?