How to remove shadow under action bar using AppCompat.Light.NoActionBar?

I tried to remove the shadow under the toolbar using Theme.AppCompat.Light.NoActionBar, using every recommendation of people who have ever answered it before, but no one worked. I tried

<item name="android:windowContentOverlay">@null</item> 

and

 <item name="android:windowContentOverlay">@drawable/solid_line</item> .... <shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"> <solid android:color="@color/accueil_color" /> <size android:height="15dp" /> </shape> 

and wherein

 android:elevation="0dp" 

the shadow comes out of the top of the screen but does not disappear.

Do you have an idea to completely remove this shadow line?

+35
android toolbar
Jul 18 '15 at 13:29
source share
8 answers

I am not an expert, but I ran into the same problem just a few hours ago. So the idea is that with AppCompat we need to manage library attributes, not Android attributes. In other words, instead of android: elevation try app: elevation:

 <android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" android:fitsSystemWindows="true" app:elevation="0dp"> <android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="match_parent" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> </android.support.design.widget.AppBarLayout> 

EDIT:

I just tried another option without AppBarLayout . This method works fine for me, the shadow has completely disappeared. Therefore, I suspect that the problem is in your other view. I don't think your ToolBar shadow casts a shadow.

 <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?attr/actionBarSize" app:elevation="0dp" /> 
+73
Jul 18 '15 at 15:40
source share
β€” -

use app:elevation="0dp" instead of android:elevation

+63
Sep 17 '15 at 10:35
source share

I had the same problem. Using app:elevation="0dp" on android.support.design.widget.AppBarLayout solves the problem

+43
Sep 20 '15 at 15:33
source share

Add app:elevation="0dp" to the AppBarLayout and the shadow will be hidden.

+16
Jan 14 '16 at 15:15
source share

I had the same problem.

If the toolbar is inside android.support.design.widget.AppBarLayout Adding an application: elevation = "0dp" to android.support.design.widget.AppBarLayout will solve your problem.

The rest is to add app:elevation="0dp" in the Toolbar .

 <android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" android:fitsSystemWindows="true" app:elevation="0dp"> <android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="match_parent" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

Hope this helps :)

+6
May 31 '17 at 8:36 a.m.
source share

Just use super.onCreate(savedInstanceState);

 if(getSupportActionBar() != null) { getSupportActionBar().setElevation(0); } 
+4
Mar 14 '17 at 13:34 on
source share

@DmitryO Hum my xml is like this, I do not have android.support.design.widget.AppBarLayout , only a toolbar widget,

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:fab="http://schemas.android.com/apk/res-auto" xmlns:materialdesign="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" android:theme="@style/AppThemeAccueil"> <View xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="@dimen/statusBarHeight" android:background="@color/accueil_colorDark" android:elevation="@dimen/statusBarElevation"/> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:popupTheme="@style/AppThemeAccueilToolbar" android:theme="@style/AppThemeAccueilToolbar" android:id="@+id/toolbarAccueil" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?attr/actionBarSize" materialdesign:elevation="0dp" android:elevation="0dp" android:outlineProvider="background" android:layout_marginTop="@dimen/appBarTopMargin" > </android.support.v7.widget.Toolbar> </RelativeLayout> 

Did i have it? (I think this will not change the result)

+1
Jul 18 '15 at 15:50
source share

Just place the AppBarLayout inside LinearLayout in a separate XML file, and then include this XML in your main XML.

+1
May 24 '17 at 3:45 a.m.
source share



All Articles