从 BottomSheetDialog 中删除底部空间

问题描述 投票:0回答:1

如何显示下面没有空格的对话框?

这里显示对话框的代码:

BottomSheetDialog mBottomSheetDialog = new BottomSheetDialog(this);
   View sheetView = getLayoutInflater().inflate(R.layout.bottom_dialog, null);
   mBottomSheetDialog.setContentView(sheetView);
   mBottomSheetDialog.show();

这里Style.xml设置对话框样式

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="bottomSheetDialogTheme">@style/BottomSheetDialog</item>
</style>

<style name="NoBackgroundDialogTheme" parent="Theme.AppCompat.Light.Dialog">
    <item name="android:windowBackground">@null</item>
</style>

<style name="BottomSheetDialog" parent="Theme.Design.Light.BottomSheetDialog">
    <item name="bottomSheetStyle">@style/bottomSheetStyleWrapper</item>
    <item name="android:windowIsFloating">false</item>
    <item name="behavior_hideable">true</item>
    <item name="behavior_peekHeight">500dp</item>
</style>
android dialog
1个回答
0
投票

评论里文章写的给了我一些思考。这个导航当然可以通过flags去掉,但是去掉的时候有1秒左右的延迟,但是下面还有空的空间。 所以我读了其他类似的答案,只是把面板漆成白色。

View decorView = mBottomSheetDialog.getWindow().getDecorView();
mBottomSheetDialog.getWindow().setNavigationBarColor(R.color.white);                mBottomSheetDialog.getWindow().setNavigationBarDividerColor(R.color.white);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                   decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
                }
© www.soinside.com 2019 - 2024. All rights reserved.