Skip to content
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

Recyclerview scrolls down when soft keyboard appears or disappears #103

Open
CallumCoombes opened this issue Oct 25, 2017 · 7 comments
Open

Comments

@CallumCoombes
Copy link

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?

@amirziarati
Copy link

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

@andriizhumela
Copy link
Contributor

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>

@jQrgen
Copy link

jQrgen commented Jul 31, 2018

@andriizhumela Thanks!

@Kamiiru8
Copy link

Kamiiru8 commented Aug 2, 2018

@andriizhumela Works beautiful <3

@mahmoudh3sham
Copy link

@andriizhumela Life saver <3

@hamamd-et
Copy link

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

@Stevengez
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants