D
Size: a a a
D
FL
D
D
A
D
FL
A
FL
S
val minKeyboardHeightPx = 150
val decorView = requireActivity().
window.
decorViewval onGlobalLayoutListener = object : ViewTreeObserver.OnGlobalLayoutListener {
private val windowVisibleDisplayFrame = Rect()
private var lastVisibleDecorViewHeight = 0
override fun onGlobalLayout() {
decorView.getWindowVisibleDisplayFrame(windowVisibleDisplayFrame)
val windowVisibleDecorViewHeight = windowVisibleDisplayFrame.height()
if (lastVisibleDecorViewHeight != 0) {
if (lastVisibleDecorViewHeight > (windowVisibleDecorViewHeight + minKeyboardHeightPx)) {
val currentKeyboardHeight = decorView.
height - windowVisibleDisplayFrame.bottom
scrollContainerView.smoothScrollBy(0, currentKeyboardHeight)
} else if (windowVisibleDecorViewHeight > (lastVisibleDecorViewHeight + minKeyboardHeightPx)) {
scrollContainerView.stopNestedScroll()
// <—
вообще верный код?
}
}
lastVisibleDecorViewHeight = windowVisibleDecorViewHeight
}
}
decorView.
viewTreeObserver.addOnGlobalLayoutListener(onGlobalLayoutListener)
scrollContainerView.smoothScrollBy(0, currentKeyboardHeight)
scrollContainerView.stopNestedScroll()
соответственно. Потом у меня меняется root screen (я использую чичероне, если кому это поможет) и на одном из фрагментов я могу обратно поменять рут скрин к логину, но у меня приложение крэшится с ошибкой:java.lang.IllegalStateException: Can't access the Fragment View's LifecycleOwner when getView() is null i.e., before onCreateView() or after onDestroyView().
Б
Б
A
FL
A
FL
Б
Б
Б