2016-05-13 111 views
1

我有AppBarLayoutToolbar在活动和TabLayout到我的片段。如何将工具栏阴影设置为零,以便在工具栏和Tablayout之间平滑放置?AppBarLayout和工具栏设置无阴影

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:elevation="0dp" 
    android:theme="@style/SDK.Theme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:minHeight="?attr/actionBarSize" 
     app:elevation="0dp" 
     local:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
     local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

回答

1

您可以以编程方式去除阴影。

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {    
    appBar.setElevation(0); 
} 

其中appBar是你的AppBarLayout

编辑:

我刚才注意到您使用android:elevation="0dp"属性。如果你想通过xml来使用app:elevation="0dp"

+0

我不明白我在哪里错了,但设置这与任何应用程序:或android:不会帮助,但它与代码设置帮助 –

+0

应用程序:应该使用AppBarLayout是在支持库中。但我不知道为什么它不适合你。 –