1

I am trying to remove the shadow cast over the Toolbar by the navigation drawer when it is pulled out whilst also allowing the shadow to be cast over the rest of the layout.

I understand I can remove the shadow by wrapping the DrawerLayout in a parent view and adding the Toolbar in that parent view but by doing this I am unable to make the Toolbar scroll off screen when the layout is scrolled so this is not a viable solution for me.

I may be able to programatically scroll the Toolbar off the screen using the offset listener of the AppBarLayout but a purely XML solution may be best.

I am using this layout:

    <android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".MainActivity"
    >


    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipChildren="true"
        >

           <android.support.design.widget.AppBarLayout
            app:layout_scrollFlags="scroll"
            android:id="@+id/profile_screen_appBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            android:fitsSystemWindows="true"
            android:minHeight="150dp"             
            >

            <android.support.design.widget.CollapsingToolbarLayout
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.7"
                app:layout_scrollFlags="scroll"
                android:fitsSystemWindows="true"
                android:id="@+id/collapsingToolbarCurrentUser"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                             >

                <android.support.v7.widget.Toolbar
                    android:minHeight="0dp"
                    android:fitsSystemWindows="false"
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                                     />
</android.support.design.widget.CollapsingToolbarLayout>

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

 <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/recycler"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            />

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

    <fragment
        android:fitsSystemWindows="true"
        android:id="@+id/fragment_drawerInTesterActivity"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:layout="@layout/fragment_nav_bar"
        android:name="Fragment"
        tools:layout="@layout/fragment_nav_bar"/>

</android.support.v4.widget.DrawerLayout>

Problem in a nutshell: How do I remove the shadow cast by the navigation drawer over the Toolbar whilst allowing the Toolbar to be a scrollable view inside a CoordinatorLayout ?

Micah Simmons
  • 2,078
  • 2
  • 20
  • 38

1 Answers1

0

This answer helped to me. Add this to the AppBarLayout:

android:elevation="0dp"
app:elevation="0dp"

CoordinatorLayout doesn't affect on shadow, even when you change it to LinearLayout.

Community
  • 1
  • 1
CoolMind
  • 26,736
  • 15
  • 188
  • 224