工具栏上的波纹效果被切断 [英] Ripple effect on Toolbar cut off
问题描述
我在我的应用程序中使用了Toolbar
,并通过菜单对其进行了填充.
我这里有一个问题,因为波纹效果会自动添加到按钮上,但是最左侧按钮的波纹效果会被菜单区域的边界所截断.
您可以看到波纹在扩大,但在左侧却逐渐消失.
知道如何解决此问题吗?
I'm using a Toolbar
in my app and am inflating it with a menu.
I have a issue here because the ripple effect is automatically added to the button but the left most button's ripple effect is cut off by the boundary of the menu area.
You can see the ripple expand but it is then but off on the left side.
Any idea how to remedy this issue?
推荐答案
我也遇到了这个问题,在玩耍之后,我发现我们的自定义ThemeOverlay
具有其背景设置.
I came across this too, after playing around I found our custom ThemeOverlay
had its background set.
尝试从工具栏样式和主题中删除android:background
.
Try removing android:background
from your Toolbar style and theme.
请参见下文,我将其注释掉:<item name="android:background">@color/toolbar</item>
.之后,它按预期工作.
See below I commented out: <item name="android:background">@color/toolbar</item>
. It works as expected after that.
<style name="MyTheme.Overlay"
parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:textColorPrimary">@color/text_primary</item>
<item name="android:textColorSecondary">@color/text_secondary</item>
<item name="android:windowBackground">@color/background</item>
<!--<item name="android:background">@color/toolbar</item>-->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">@color/toolbar</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/toolbar</item>
<!-- colorAccent is used as the default value for colorControlActivated,
which is used to tint widgets -->
<item name="colorAccent">@color/accent</item>
</style>
这篇关于工具栏上的波纹效果被切断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!