Android BottomSheet: Is hiding under the toolbar

前端 未结 2 1029
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-30 03:12

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 v

相关标签:
2条回答
  • 2020-12-30 03:21

    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

    0 讨论(0)
  • 2020-12-30 03:38

    If the above answer doesn't help, try to set to your BottomSheet:

    android:elevation="@dimen/design_appbar_elevation" android:fitsSystemWindows="true"

    and create your Fragment such way:

    videoFragment = VideoFragment.newInstance(); getSupportFragmentManager().beginTransaction() .replace(R.id.video_fragment, videoFragment) .commit();
    not like this: videoFragment = (VideoFragment) getSupportFragmentManager().findFragmentById(R.id.video_fragment);

    For example I have such layout:

    <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:background="@color/activity_background">
    
    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.ActionBar">
    
        <include layout="@layout/toolbar"/>
    
    </android.support.design.widget.AppBarLayout>
    
    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
    
    <android.support.design.widget.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        app:itemBackground="@color/white"
        app:menu="@menu/bottom_navigation_main"/>
    
    <FrameLayout
        android:id="@+id/video_fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:elevation="@dimen/design_appbar_elevation"
        android:fitsSystemWindows="true"
        app:behavior_hideable="true"
        app:behavior_peekHeight="0dp"
        app:layout_behavior="android.support.design.widget.BottomSheetBehavior"/>
    


    and it doesn't work without specified things

    0 讨论(0)
提交回复
热议问题