2

I have a problem with BottomSheetDialog and software navigation bar. If I create BottomSheetDialog:

    BottomSheetDialog mBottomSheetDialog = new BottomSheetDialog(mContext);
    View sheetView = inflater.inflate(R.layout.bottom_sheet_sentence, (ViewGroup)view.getParent(), false);
    mBottomSheetDialog.setContentView(sheetView);
    mBottomSheetDialog.show();

then on devices with the software navigation bar, the dialog is shown below/under the navigation bar (in this example it's a tablet with Android 7.0, it's not so visible but the second button is below the navigation bar):

enter image description here

How can I add the BottomSheetDialog above the navigation bar?

Pepa Zapletal
  • 2,879
  • 3
  • 39
  • 69

2 Answers2

0

int theme= R.style.BottomSheetDialogTheme;

BottomSheetDialog mBottomSheetDialog = newBottomSheetDialog( context, theme);

Add this code in style.xml

 <style name="BottomSheetDialogTheme" parent="BaseBottomSheetDialog">
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>
  • I tried it but this is not working. I have to move somehow BottomSheetDialog above the navigation bar. – Pepa Zapletal Nov 21 '19 at 21:06
  • mBottomSheetDialog.setOnShowListener(dialog1 -> { BottomSheetDialog d = (BottomSheetDialog) dialog1; FrameLayout bottomSheet = d.findViewById(com.google.android.material.R.id.design_bottom_sheet); BottomSheetBehavior.from(bottomSheet) .setState(BottomSheetBehavior.STATE_EXPANDED); }); //please add this piece of code after creating the object it is working i tried. – sandeep kella Nov 21 '19 at 21:53
  • I tried it and still not working. The bottom part (second button) is still below navigation bar. – Pepa Zapletal Nov 22 '19 at 07:53
  • android:paddingBottom="@android:dimen/navigation_bar_height" // Add this piece of code to the view which is hiding behind the navigation bar. – sandeep kella Nov 22 '19 at 09:13
0

I think your problem is you're not define window system UI flag.

please check this related question

I'm usually use this method to prevent my single components or view group inflating under Soft Navigation Bar

MyActivity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
hnspaces
  • 44
  • 8