PopUpWindow ignores fullscreen and also the CutoutMode

367 views Asked by At

My app is a full screen app. It goes full width and does not show a status bar, uses CutoutMode and hides controls like (Home and Back). This also works well.

However, when I create a PopUpWindow, these settings don't seem to take effect. See the following image:

enter image description here

I would have expected that the quadrangles marked in red on the left and right would also be in the corresponding shade of gray.

My code to initialize the PopUp Window looks like this:

 val inflater =
        view.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as? LayoutInflater
            ?: return

    // Inflate a custom view using layout inflater
    val popUpView = inflater.inflate(R.layout.view_change_name, null)

    //popUpView.animation = AnimationUtils.loadAnimation(view.context, R.anim.fade_in_animation)
    // Initialize a new instance of popup window
    val popupWindow = PopupWindow(
        popUpView, // Custom view to show in popup window
        LinearLayout.LayoutParams.MATCH_PARENT, // Width of popup window
        LinearLayout.LayoutParams.MATCH_PARENT, // Window height
        true
    )
    popupWindow.animationStyle = R.style.PopUpWindowAnimation
    popupWindow.isFocusable = true
    popupWindow.isOutsideTouchable = true
    popupWindow.update(
        0,
        0,
        ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT
    )

    //Set the location of the window on the screen
    popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0)

My method to get the full screen in my activity works like this.

fun Activity.fullscreen() {
    with(WindowInsetsControllerCompat(window, window.decorView)) {
        systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE
        hide(Type.systemBars())
    }
}

So my idea was to get a decorView in the PopUpWindow. But I think the PopUpWindow has not a decorView. I'm running out of ideas. Does anyone have an approach or solution?

1

There are 1 answers

0
kuzdu On

How stupid. After I post this question I found an answer.

Use

popupWindow.isClippingEnabled = false

Documentation

@param enabled false if the window should be allowed to extend outside of the screen