Android BottomSheet: Is hiding under the toolbar

Paul Woitaschek picture Paul Woitaschek · Mar 1, 2016 · Viewed 14.1k times · Source

I tried to use the new bottom sheet from the support library 23.2.0 to have a bottom sheet expand to full screen like suggested in the design guidelines

This works very good but the bottom sheet goes under my ActionBar and under my tabs.

How is it possible to let the bottom sheet go over the toolbar? My menu is structured like this:

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/appbar_padding_top">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|snap|enterAlways"
            app:popupTheme="@style/AppTheme.PopupOverlay"/>

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

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

    <android.support.v4.view.ViewPager
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

    <include
        android:id="@+id/playerLayout"
        layout="@layout/player_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:behavior_peekHeight="?attr/actionBarSize"
        app:layout_behavior="@string/bottom_sheet_behavior"
        app:model="@{model}"/>

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

enter image description here

Answer

ianhanniballake picture ianhanniballake · Mar 1, 2016

The AppBarLayout has a default elevation of 4dp (the dimension resource value design_appbar_elevation).

By default CoordinatorLayout, like any FrameLayout, will layout elements with higher elevation before lower elevation on API 21 and higher devices.

Try adding android:elevation="@dimen/design_appbar_elevation" to your layout.

Note that the elevation of a modal bottom sheet is @dimen/design_bottom_sheet_modal_elevation == 16dp