Sté*_*ane 11 android material-design android-5.0-lollipop
在Android Lollipop上,我正在使用:
android:background="?android:attr/selectableItemBackground"
Run Code Online (Sandbox Code Playgroud)
单击按钮时获得材料动画反馈.
当我有一个包含在白色/浅色布局中的按钮(例如CardView)时,它可以正常工作.
但是当我想在深色背景上使用相同的东西时,我们几乎看不到效果,它不够明显.
有人有想法吗?
谢谢
ala*_*anv 22
在API 21+你可以设置android:theme="@android:style/ThemeOverlay.Material.Dark"一个View或ViewGroup更改所有主题属性(文本颜色,色彩波纹,按钮颜色等)的"黑暗"的版本.如果将其设置为a 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>
Run Code Online (Sandbox Code Playgroud)
AppCompat 解决方案(也适用于旧 API)
android:theme="@style/Base.ThemeOverlay.AppCompat.Dark"
android:background="?attr/selectableItemBackground"
Run Code Online (Sandbox Code Playgroud)