ChatKit icon indicating copy to clipboard operation
ChatKit copied to clipboard

Recyclerview scrolls down when soft keyboard appears or disappears

Open CallumCoombes opened this issue 6 years ago • 7 comments

The issue is that the recyclerview scrolls down almost a complete row when the soft keyboard appears or disappears.

Here is a visual example

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?

CallumCoombes avatar Oct 25 '17 16:10 CallumCoombes

happens to me too. I changed my wrapping group view to linear and it solved my problem but thats not the solution :/

amirziarati avatar Mar 01 '18 06:03 amirziarati

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 avatar Jul 03 '18 13:07 andriizhumela

@andriizhumela Thanks!

jQrgen avatar Jul 31 '18 11:07 jQrgen

@andriizhumela Works beautiful <3

Kamiiru8 avatar Aug 02 '18 11:08 Kamiiru8

@andriizhumela Life saver <3

mahmoudh3sham avatar Apr 05 '19 21:04 mahmoudh3sham

@andriizhumela is right, setting either the height or setting proper constraints for all edges will solve the problem.

hamamd-et avatar Aug 01 '19 16:08 hamamd-et

this works fine when is set to adjustPan, but with adjustResize happens exact the same result, any suggestion?

Stevengez avatar Jun 10 '20 20:06 Stevengez