4

App normally has this navigation bar:

enter image description here

But when I add ViewCompat.setOnApplyWindowInsetsListener()

ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { _, insets ->
    binding.showingKeyboard = insets.isVisible(WindowInsetsCompat.Type.ime())
    WindowInsetsCompat.CONSUMED
}

or

ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { _, insets ->
    binding.showingKeyboard = insets.isVisible(WindowInsetsCompat.Type.ime())
    insets
}

it becomes like this

enter image description here

Why does it happen? I don't want this method to change anything. I just want to use it to detect if the virtual keyboard is visible or not (there are no other good methods to do it)

user924
  • 8,146
  • 7
  • 57
  • 139

1 Answers1

0

Call setOnApplyWindowInsetsListener on root view of your layout, not on window.decorView