在 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/