删除阴影之下动作条阴影、动作

2023-09-12 21:31:57 作者:恍若の心逝

我用actionbarsherlock。下一张code是负责改变它的背景,以一个自定义。

 <样式名称=Widget.Styled.ActionBar父=Widget.Sherlock.ActionBar>
    <项目名称=背景> @可绘制/ actionbar_bg< /项目>
    <项目名称=机器人:背景> @可绘制/ actionbar_bg< /项目>
    < ...>
< /风格>

<样式名称=Theme.MyApp父=@风格/ Theme.Sherlock.Light>
    <项目名称=actionBarStyle> @风格/ Widget.Styled.ActionBar< /项目>
    <项目名称=机器人:actionBarStyle> @风格/ Widget.Styled.ActionBar< /项目>
    < ..>
< /风格>
 

和它适用于actionbarsherlock(下面蜂窝版本)。但在ICS我下面这动作条影,我不想要的。 什么是风格的项目,使之消失?

解决方案   

什么是风格的项目,使之消失?

为了去除阴影将它添加到您的应用程序的主题:

 <样式名称=MyAppTheme父=机器人:Theme.Holo.Light>
    <项目名称=机器人:windowContentOverlay> @空< /项目>
< /风格>
 
ps怎么把人物阴影去掉

更新: 正如@ Quinny898指出,在Android 5.0这种情况已经改变,你必须调用 setElevation(0)在你的动作条。请注意,如果你使用的是支持库必须调用它,像这样:

  getSupportActionBar()setElevation(0)。
 

I use actionbarsherlock. The piece of code below is responsible for changing it's background to a custom one.

<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.ActionBar">
    <item name="background">@drawable/actionbar_bg</item>
    <item name="android:background">@drawable/actionbar_bg</item>
    <...>  
</style>

<style name="Theme.MyApp" parent="@style/Theme.Sherlock.Light">
    <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
    <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
    <..>
</style>

And it works for actionbarsherlock (on versions below honeycomb). But in ICS I have a shadow below actionbar which I don't want. What is the style item to make it disappear?

解决方案

What is the style item to make it disappear?

In order to remove the shadow add this to your app theme:

<style name="MyAppTheme" parent="android:Theme.Holo.Light">
    <item name="android:windowContentOverlay">@null</item>
</style>

UPDATE: As @Quinny898 stated, on Android 5.0 this has changed, you have to call setElevation(0) on your action bar. Note that if you're using the support library you must call it to that like so:

getSupportActionBar().setElevation(0);