-
-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not working with the activity using dialog theme #68
Comments
I managed to make it work in a Dialog with the following code, unfortunately bypassing the KeyboardVisibilityEvent library: private fun setKeyboardListener() {
// Top-level window decor view.
val decorView = activity?.window?.decorView
// Register global layout listener.
decorView?.viewTreeObserver?.addOnGlobalLayoutListener(object :
ViewTreeObserver.OnGlobalLayoutListener {
// Retrieve visible rectangle inside window.
private val windowVisibleDisplayFrame: Rect = Rect()
private var lastVisibleDecorViewHeight = 0
override fun onGlobalLayout() {
decorView.getWindowVisibleDisplayFrame(windowVisibleDisplayFrame)
val visibleDecorViewHeight: Int = windowVisibleDisplayFrame.height()
if (lastVisibleDecorViewHeight != 0) {
if (lastVisibleDecorViewHeight > visibleDecorViewHeight + MIN_KEYBOARD_HEIGHT_PX) {
binding.keyboardIsOpen = true
} else if (lastVisibleDecorViewHeight + MIN_KEYBOARD_HEIGHT_PX < visibleDecorViewHeight) {
binding.keyboardIsOpen = false
}
}
// Save current decor view height for the next call.
lastVisibleDecorViewHeight = visibleDecorViewHeight
}
})
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have activity A (normal theme) register keyboard listener event. From A, I start activity B (dialog theme & register keyboard listener event too), when keyboard changed, I only receive the event on A, not on B.
Can you help me? I want to receive the event on activity B.
The text was updated successfully, but these errors were encountered: