简体   繁体   中英

Android - BottomSheetDialog is under software NavigationBar

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):

在此处输入图像描述

How can I add the BottomSheetDialog above the navigation bar?

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 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM