移除ActionBar下方的阴影。

219

我使用actionbarsherlock。下面的代码片段负责将其背景更改为自定义背景。

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

它适用于ActionBarSherlock(在Honeycomb版本以下)。但是,在ICS中,我的操作栏下方有一个阴影,我不想要。 有什么样式项可以使它消失?

14个回答

1
对于 Xamarin 开发者,请使用以下代码:SupportActionBar.Elevation = 0;(针对 AppCompatActivity)或 ActionBar.Elevation = 0;(针对非兼容的 Activities)。

1
尝试这个,它帮助我而不改变主题。将您的AppBarLayout放置在任何布局中。希望这能帮到您。
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="false"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">


    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        android:layout_height="?attr/actionBarSize"
       android:background="@color/white">
        <ImageView
            android:src="@drawable/go_grocery_logo"
            android:layout_width="108dp"
            android:layout_height="32dp" />
    </android.support.v7.widget.Toolbar>


</android.support.design.widget.AppBarLayout>
</RelativeLayout>

0

对于那些在处理片段时,设置toolbar.getBackground().setAlpha(0);或任何消失后的情况,我认为您必须将AppBarLayout放在xml中的最后,因此它是Fragment然后是AppBarLayout,然后是相对布局/约束/线性布局,无论您使用哪种。


0

使用:

outLineAmbientShadowColor="@null"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接