Android: I cannot remove elevation / shadow on my toolbar

You can do that with an easy step. Don't remove the android.support.design.widget.AppBarLayout from your layout, instead add the attribute app:elevation="0dp" to it. Your final layout will be:

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

This remove elevation on toolbar (android:stateListAnimator="@null"), stateListAnimator is for API level 21 or higher, so insert a tools prop (before namespace declaration) like this:

//xmlns:tools="http://schemas.android.com/tools" in parent or start element

     <android.support.design.widget.AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:stateListAnimator="@null" 
        android:theme="@style/AppTheme.AppBarOverlay"
        tools:targetApi="21">

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

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

//your content goes here like RecyclerView, Card or other layout 

Here is my sample result:

enter image description here


Use setOutlineProvider(null); on your appBar. Just be sure to check the SDK version. :)


Use app:elevation="0dp" in your AppBarLayout. Make sure you put Toolbar inside your AppBarLayout like this -

    <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/AppTheme.AppBarOverlay"
        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"
            android:background="@color/firstOption"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

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

and add this line to your activity - findViewById(R.id.appBarLayout).bringToFront();
This will bring the AppBar to front.