Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private fun listenKeyboardChanged() {
- rootLayoutInFragment.getViewTreeObserver().addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
- override fun onGlobalLayout() {
- val screenHeight = mBinding!!.rootLayout.rootView.height
- var rect = Rect()
- activity.window.decorView.getWindowVisibleDisplayFrame(rect)
- val keyboardHeight = screenHeight - rect.bottom - getActionBarSize()
- val defaultLineHeight = CommonUtils.dpToPx(1)
- if (keyboardHeight > 150) {
- //updateViewWhenKeyboardChanged(true, keyboardHeight)
- // show keyboard
- } else {
- // hide keyboard
- //updateViewWhenKeyboardChanged(false, defaultLineHeight)
- }
- }
- })
- }
- private fun getActionBarSize(): Int {
- val styledAttributes = activity.getTheme().obtainStyledAttributes(intArrayOf(android.R.attr.actionBarSize))
- val actionBarSize = styledAttributes.getDimension(0, 0f).toInt()
- styledAttributes.recycle()
- return actionBarSize
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement