Immersive Mode showing blank space

后端 未结 5 1244
孤独总比滥情好
孤独总比滥情好 2020-12-29 05:48

I\'m trying to implement a fullscreen mode, but for Android 4.4 and up, it shows a blank space there:

BEFORE immersive mode(fullscreen)

5条回答
  •  温柔的废话
    2020-12-29 06:18

    Try this:

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        var viewParent = view
        while (viewParent is View) {
            viewParent.fitsSystemWindows = false
            viewParent.setOnApplyWindowInsetsListener { _, insets -> insets }
            viewParent = viewParent.parent as View?
        }
    }
    

    What does this do? DialogFragment#onActivityCreated() calls Dialog#setContentView(), which wraps the Dialog's view in a private 'wrapInBottomSheet'. In order to set the proper flags of those wrapper views, we want to set the flags after they are wrapped, e.g. after super.onActivityCreated()

    Also watch this talk for info on fitsSystemWindows and window insets.

提交回复
热议问题