android - 删除 Android 中 BottomSheet Fragment 中导航栏的间隙/边距

标签 android bottom-sheet

我正在使用 Bottom Sheet fragment 来显示弹出窗口。 我用过https://stackoverflow.com/a/51329005/5519745设置导航栏颜色。但是,在某些设备中,导航栏和 Bottom Sheet 对话框之间存在间隙。

enter image description here

最佳答案

我使用了与您相同的堆栈溢出解决方案在导航栏上设置白色背景并遇到了相同的问题。

我通过将 setWhiteNavigationBar setLayerInsetTop metrics.heightPixels 字段更新为一个小减值来解决这个问题,使 Bottom Sheet 向下移动少量。

希望这有帮助。


原创

windowBackground.setLayerInsetTop(1, metrics.heightPixels);

Original with gap between bottomsheet and navbar


修改

windowBackground.setLayerInsetTop(1, metrics.heightPixels - 2);

enter image description here


关于android - 删除 Android 中 BottomSheet Fragment 中导航栏的间隙/边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61250637/

相关文章:

android - 单击 NavigationDrawer 不打开 Bottom Sheet

android - 像 super 应用程序一样的 Bottom Sheet

android - 添加一个用C编写的新SDK到android中

android - 在 Android Studio 中使用预构建库和 jni

android - 布局太高的地方未显示 ListView

android - 来自同一资源图像的多个可绘制对象

android - 从设置 Activity 发送 WallpaperService 时需要 BIND_WALLPAPER 权限

java - 在 Bottom Sheet 中更新 recyclerview 内容失败

android - 了解 BottomSheet 行为折叠与隐藏

android - Bottom Sheet 向下滑动行为