【问题标题】:How to implement edge-to-edge with bottomsheet dialog android如何使用bottomsheet对话框android实现边到边
【发布时间】:2022-10-18 01:41:12
【问题描述】:

我有一个完全基于沉浸式模式的 android 应用程序。我已经设法对整个应用程序进行边对边处理,但是当我打开一个底部工作表对话框时,其窥视高度为屏幕顶部的 90% 和一个滚动视图以适应长表单。但是,当我打开底部工作表时,视图底部有一个空白区域,正好是系统导航栏的大小。有没有办法删除那个空间,让底部的纸张一直延伸到屏幕的底部?

这是底部工作表完全展开的快照

【问题讨论】:

    标签: android android-10.0 android-gesture android-bottomsheetdialog


    【解决方案1】:

    在你的底部SheetFragment 覆盖 fun onCreateDialog(savedInstanceState: Bundle?): Dialog = 对象:BottomSheetDialog(requireContext(),主题){ 覆盖有趣的 onAttachedToWindow() { super.onAttachedToWindow()

                window?.let {
                    WindowCompat.setDecorFitsSystemWindows(it, false)
                }
    
                findViewById<View>(com.google.android.material.R.id.container)?.apply {
                    fitsSystemWindows = false
                    ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets ->
                        insets.apply {
                            view.updatePadding(bottom = 0)
                        }
                    }
                }
    
                findViewById<View>(com.google.android.material.R.id.coordinator)?.fitsSystemWindows = false
            }
        }
    

    在泰晤士河: @style/底页对话框主题

    在风格 @style/AppModalStyle @颜色/透明 错误的 错误的 @颜色/透明

    <style name="AppModalStyle" parent="Widget.Design.BottomSheet.Modal">
        <item name="android:background">@null</item>
    </style>
    

    【讨论】:

      猜你喜欢
      • 2010-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 1970-01-01
      • 2015-09-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多