ChatKit
ChatKit copied to clipboard
Recyclerview scrolls down when soft keyboard appears or disappears
The issue is that the recyclerview scrolls down almost a complete row when the soft keyboard appears or disappears.
The layout for the activity uses a MessageInput and MessageList object and is as follows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="apps.cal.calchat.ChatActivity.ChatView">
<TextView
android:id="@+id/chatIsTypingTextView"
android:layout_width="match_parent"
android:layout_marginLeft="8dp"
android:layout_height="wrap_content"
android:layout_above="@+id/chatMessageInput"/>
<com.stfalcon.chatkit.messages.MessageInput
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:id="@+id/chatMessageInput"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<com.stfalcon.chatkit.messages.MessagesList
android:id="@+id/chatMessagesList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="@+id/chatIsTypingTextView"
/>
</RelativeLayout>
The activity also has adjustPan set in the manifest:
<activity
android:name=".ChatActivity.ChatView"
android:windowSoftInputMode="adjustPan|stateHidden"/>
I have not changed the Recyclerview's linear layout manager from within the MessageList class.
I ideally do not want to set up a keyboard listener and programatically scroll to the bottom every time the keyboard is shown/hidden. It seems that I must be doing something wrong somewhere. Any ideas?
happens to me too. I changed my wrapping group view to linear and it solved my problem but thats not the solution :/
For the correct behavior of the MessagesList, you must specify the size of it. In your case, it is enough to specify the maximum height as mach_parent. For example, this code will display correctly
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.stfalcon.chatkit.messages.MessagesList
android:id="@+id/messagesList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/chatIsTypingTextView"
android:layout_alignParentTop="true" />
<TextView
android:id="@+id/chatIsTypingTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/input"
android:layout_marginLeft="8dp" />
<com.stfalcon.chatkit.messages.MessageInput
android:id="@+id/input"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
@andriizhumela Thanks!
@andriizhumela Works beautiful <3
@andriizhumela Life saver <3
@andriizhumela is right, setting either the height or setting proper constraints for all edges will solve the problem.
this works fine when is set to adjustPan, but with adjustResize happens exact the same result, any suggestion?