0

In the chat screen, LAYOUT1. When keyboard open the top view and recyclerview stays where they are and bottom Layout with edit text is adjusted. On redmi, poco and Samsung devices. But it doesn't work on pixel 7 device the keyboard appear on top of layout

 <activity
 android:name=".ActivityChat"
 android:exported="true"
 android:screenOrientation="portrait" />

enter image description here

when I use

 android:windowSoftInputMode="adjustPan"

The entire layout is scroll up and bottom Layout is not fully visible. Edittext is focused. It doesn't look good for all devices. I want the first scenario on pixel 7.

picture 2 with adjustpan

asked Feb 19, 2025 at 11:38

1 Answer 1

0

By enabling edge to edge stop default activity padding on all devices.

 enableEdgeToEdge()

this listener will be called when edge to edge is enabled and you need to manually set padding when keyboard opens

 ViewCompat.setOnApplyWindowInsetsListener(binding!!.main) { view, windowInsets ->
 val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemGestures())
 val imeInsets = windowInsets.getInsets(WindowInsetsCompat.Type.ime())
 val isKeyboardVisible = imeInsets.bottom > 0
 val keyboardHeight = imeInsets.bottom
 if (isKeyboardVisible) {
 Log.e("KeyboardStatus", "Keyboard opened. Height: $keyboardHeight")
 view.updatePadding(0, 0, 0, keyboardHeight)
 moveToBottom()
 } else {
 view.updatePadding(0, 0, 0, insets.bottom)
 Log.e("KeyboardStatus", "Keyboard closed")
 }
 WindowInsetsCompat.CONSUMED
 }

This now works both on Pixel 7 and Xiaomi devices.

answered Feb 20, 2025 at 5:54
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.