buellas
buellas

Reputation: 331

Can a BottomSheet be shown behind another view?

Is it possible to open a BottomSheet behind another view? (In my case a button) What kind of layout should I use for that?

enter image description here

Upvotes: 4

Views: 2763

Answers (1)

Jukurrpa
Jukurrpa

Reputation: 4168

You should be able to achieve this with a layout like this one, which worked in my case:

<androidx.coordinatorlayout.widget.CoordinatorLayout>

    <View
        android:id="@+id/bottomSheet"
        app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"/>

    <View android:id="@+id/viewYouWantAbove"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

So the view you want to be above the bottom sheet simply needs to be after the bottom sheet in the xml.

Note: If your bottom sheet has an elevation, the other view must have a superior or equal elevation to be above.

Upvotes: 2

Related Questions