Remove android.widget.Toolbar shadow Remove android.widget.Toolbar shadow java java

Remove android.widget.Toolbar shadow


Use app:elevation="0dp" instead of android:elevation on your toolbar.If it is not work, put your toolbar inside of a AppBarLayout and set app:elevation="0dp":

<android.support.design.widget.AppBarLayout            android:id="@+id/appBarLayout"            android:layout_width="match_parent"            android:layout_height="wrap_content"            app:elevation="0dp">            ...</android.support.design.widget.AppBarLayout>


Use attribute app:elevation="0dp" to your Toolbar or AppBarLayout to remove the shadow.

#. If you are using Toolbar only, then add attribute app:elevation="0dp" to Toolbar.

    <android.support.v7.widget.Toolbar        android:id="@+id/toolbar"        android:layout_width="match_parent"        android:layout_height="?attr/actionBarSize"        android:background="?attr/colorPrimary"        app:popupTheme="@style/AppTheme.PopupOverlay"        app:elevation="0dp"/>

#. If you are using AppBarLayout as a container of Toolbar, then add attribute app:elevation="0dp" to AppBarLayout.

    <android.support.design.widget.AppBarLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:theme="@style/AppTheme.AppBarOverlay"        app:elevation="0dp">        <android.support.v7.widget.Toolbar            android:id="@+id/toolbar"            android:layout_width="match_parent"            android:layout_height="?attr/actionBarSize"            android:background="?attr/colorPrimary"            app:popupTheme="@style/AppTheme.PopupOverlay" />    </android.support.design.widget.AppBarLayout>

OUTPUT:

enter image description here

UPDATE:

If you want to remove it programmatically then you can use below code:

getSupportActionBar().setElevation(0);

Hope this will help~


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"           app:elevation="0dp"></android.support.design.widget.AppBarLayout>