android - 自定义 selectableItemBackground

标签 android android-styles android-recyclerview

我正在为列表使用 RecyclerView。我找到了一个非常好的解决方案来提供列表点击反馈和涟漪(在 Lollipop 上)。 基本上我给我的行布局属性:

android:background="?android:attr/selectableItemBackground"

一切都很好,只是我的列表需要不同的背景颜色(默认状态)。我如何才能覆盖基本状态背景(未单击)以赋予它不同的颜色?

最佳答案

这将提供自定义背景颜色和默认灰色波纹效果:

android:background="@color/YourCustomColor"
android:foreground="?android:attr/selectableItemBackground"

关于android - 自定义 selectableItemBackground,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31117224/

相关文章:

android - 为什么recyclerView的findviewbyposition()有时只返回null

java - 如何在应用程序中三天显示一次对话框

android - 底部工作表按钮自定义样式不起作用

Android 可跨度 : how to clear color?

android - 渐变笔画形状

android - 无法覆盖主题的默认文本颜色(android)

android - 在打开/关闭软键盘之前,RecyclerView 不会更新

android - 触发 Android Studio 以显示方法签名?

java - 免费源代码存储库?

java - F.A.B 隐藏但不显示