android:attr/selectableItemBackground在深色背景上不够明显 [英] ?android:attr/selectableItemBackground not visible enough on a dark background

查看:638
本文介绍了android:attr/selectableItemBackground在深色背景上不够明显的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android Lollipop上,我正在使用:

On Android Lollipop, I'm using:

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

当我单击一个按钮时获得实质性的动画反馈.

to have the material animated feedback when I click on a button.

当我在白色/浅色布局中包含一个按钮(例如CardView)时,它会很好地工作.

It works well when I have a button contained in a white/light layout, like a CardView for example.

但是当我想在黑暗的背景上使用相同的东西时,我们几乎看不到效果,那是不够明显的.

But when I want to use the same thing on a dark background, we barely see the effect, it is not visible enough.

有人有主意吗?

谢谢

推荐答案

在API 21+上,您可以在ViewViewGroup上设置android:theme="@android:style/ThemeOverlay.Material.Dark"来更改所有主题属性(文字颜色,波纹颜色,按钮颜色等)更改为深色"版本.如果将其设置为ViewGroup,则该主题还将在充气期间应用于所有子元素.这是在其他亮"界面中具有暗"区域的简单方法(反之亦然).

On API 21+ you can set android:theme="@android:style/ThemeOverlay.Material.Dark" on a View or ViewGroup to change all of the theme attributes (text color, ripple color, button color, etc.) to the "dark" versions. If you set it on a ViewGroup, the theme is also applied to all of the child elements during inflation. It's an easy way to have regions of "dark" in an otherwise "light" interface (or vice versa).

<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在深色背景上不够明显的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆