android - ?安卓 :attr/selectableItemBackground not visible enough on a dark background

标签 android android-5.0-lollipop material-design

在 Android Lollipop 上,我使用:

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

当我点击一个按钮时获得 Material 动画反馈。

当我在白色/浅色布局中包含一个按钮(例如 CardView)时,效果很好。

但是当我想在深色背景上使用同样的东西时,我们几乎看不到效果,它不够明显。

有人有想法吗?

谢谢

最佳答案

在 API 21+ 上,您可以设置 android:theme="@android:style/ThemeOverlay.Material.Dark"View 上或 ViewGroup将所有主题属性(文本颜色、波纹颜色、按钮颜色等)更改为“深色”版本。如果您将其设置为 ViewGroup ,主题也适用于通货膨胀期间的所有子元素。这是在其他“浅色”界面中设置“深色”区域(反之亦然)的简单方法。

<LinearLayout
    android:id="@id/my_dark_layout"
    ...
    android:theme="@android:style/ThemeOverlay.Material.Dark">

    <TextView
        android:id="@id/my_dark_bounded_ripple"
        ...
        android:background="?android:attr/selectableItemBackground"
        android:text="Bounded ripple" />

    <ImageButton
        android:id="@id/my_dark_unbounded_ripple"
        ...
        android:background="?android:attr/selectableItemBackgroundBorderless"
        android:src="@drawable/my_icon" />

</LinearLayout>

关于android - ?安卓 :attr/selectableItemBackground not visible enough on a dark background,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28605031/

相关文章:

android - 使用耗时类型设置警报会在内核中打印来自 dmesg 的不准确延迟

css - Material Icons 有时无法在移动网络浏览器上加载

android - 如何为 Material Design Drawer 的 NavigationView 上的项目添加通知值?

java - 启动屏幕后启动另一个 Activity 而不是主 Activity

android - 这是 Android 中的 AlertDialog 或 PopupWindow 的示例吗?

android - 将 float 操作按钮变形为相关操作

android - 关于 RecyclerView.ViewHolder 和 RecyclerView.Adapter

安卓 Lollipop 联系人颜色

android - ActionBar 只显示文本

android - Buggy ListView 让我很难过