Search code examples
androidandroid-framelayout

Creating a slideUp window over the main activity if a button is clicked


I want to create a window which pops up when a button is clicked, in which I can give some buttons to be selected which can be used to provide some data to the main activity.

I tried with Dialog box and Frame layout. Problem with Dialog box is that it doesn't cover the whole screen. Problem with Frame layout using fragment transaction which I am facing is that the main activity's layout is also visible when frame layout comes into picture.

Eg.

enter image description here

But when i click on button to show the window from below:

enter image description here

ie. the image and START button from the activity is also visible. It should partially cover the activity with my fragment window I have tried with giving background color as white in FrameLayout.


Solution

  • You already tried with a Dialog, so maybe BottomSheetDialogFragment is a good choice for you since it extends from DialogFragment.

    There is a Medium blog post with a short example: Using BottomSheetDialogFragment with Material Design Guideline

    Since you need a fullscreen Dialog: BottomSheetDialogFragment - How to set expanded height (or min top offset) is an SO post about setting the expanded height of a BottomSheetDialogFragment.

    See also the material design guidelines on Modal Bottom Sheets as well as the reference