0

ViewCompat.setOnApplyWindowInsetsListener don't call when the keyboard appears,on api 29

private fun setUiWindowInsets() {
        ViewCompat.setOnApplyWindowInsetsListener(binding.root) { _, insets ->
            prevPosition = (binding.rvComments.layoutManager as LinearLayoutManager).findLastVisibleItemPosition()
            binding.container.updateLayoutParams<ViewGroup.MarginLayoutParams> {
                currentBottomMargin = insets.getInsets(WindowInsetsCompat.Type.ime()).bottom
                updateMargins(
                    bottom = currentBottomMargin
                )
                binding.rvComments.scrollToPosition(prevPosition)
            }
            insets
        }
    }

I try use WindowCompat.setDecorFitsSystemWindows(window, false)

I call this function in OnViewCreated.My root element is constraint.

cr7semen
  • 1
  • 1

1 Answers1

0

What worked for me was setting the listener on the decorView of the window as explained here:
https://stackoverflow.com/a/76163728/1441731

amitfr
  • 1,033
  • 1
  • 9
  • 29