Android soft keyboard hides RecyclerView
Asked Answered
K

3

6

I'm trying to make a comments/chat layout with a RecyclerView and a fixed EditText at the bottom. Please don't say adjustPan or adjustResize. Does not work. adjustPan hides the keyboard.

I really need help with this, it's getting really frustrating

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/appbarlayout"
        android:paddingTop="@dimen/app_bar_top_padding">

        <android.support.v7.widget.Toolbar
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
            android:id="@+id/toolbar"
            app:titleTextColor="#FFFFFF" />

    </android.support.design.widget.AppBarLayout>


    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/recycler_view"
        android:layout_below="@+id/appbarlayout"
        android:isScrollContainer="false"
        android:stackFromBottom="true"
        android:transcriptMode="normal"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#2b2b2b"
        android:orientation="vertical"
        android:id="@+id/chat_box"
        android:layout_alignParentBottom="true">

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="?android:attr/listDivider"/>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="16dp">

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:hint="Skriv en kommentar"
                android:background="@android:color/transparent"
                android:textColor="@color/white"
                android:textColorHint="#d4d4d4"
                android:inputType="textCapSentences|textMultiLine"
                android:layout_marginRight="40dp"/>

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_send"
                android:background="@drawable/click"
                android:layout_gravity="right|center_vertical" />

        </FrameLayout>

    </LinearLayout>


</RelativeLayout>

Kaleena answered 10/9, 2016 at 13:7 Comment(0)
G
0

The correct answer is adjustResize, so the app is resized above the keyboard. However for that to work the rest of your layout needs to be written to be resizable. Yours isn't, as the recycler view isn't fixed in place. Add in a layout_above="@+id/chatBox" constraint on it so it lays out above the edit text, and it should resize to fit the space properly.

Also, adjustPan doesn't hide the keyboard. If it does, you have something really wrong in your code. adjustPan slides your app up without resizing. Which may be what you want, if you can find out what in your app is hiding the keyboard.

Gastelum answered 10/9, 2016 at 13:32 Comment(1)
Not sure why, but not working for me. Having same kind of layout <relativelayout><edittext with bottom true/><recyclerview with above edittext/></relativelayout>Breunig
B
2

Not sure why, but the solution given by Gabe Sechan not worked for me. What worked for me is adding this in manifest file.

android:windowSoftInputMode="adjustPan"
Breunig answered 11/2, 2021 at 15:59 Comment(0)
N
1

My RecyclerView was moving with the keyboard, which i certainly didn't want to.

"adjustResize"

The activity's main window is always resized to make room for the soft keyboard on screen.

"adjustPan"

The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.

First approach was to set android:windowSoftInputMode="adjustResize" in manifest file, which didn't work out.

However my second approach android:windowSoftInputMode="adjustPan" as @Kishan Solanki mentioned did.

My layout is a constraint wrapping up a relative wrapping up my recyclerview

Nims answered 27/7, 2022 at 19:12 Comment(0)
G
0

The correct answer is adjustResize, so the app is resized above the keyboard. However for that to work the rest of your layout needs to be written to be resizable. Yours isn't, as the recycler view isn't fixed in place. Add in a layout_above="@+id/chatBox" constraint on it so it lays out above the edit text, and it should resize to fit the space properly.

Also, adjustPan doesn't hide the keyboard. If it does, you have something really wrong in your code. adjustPan slides your app up without resizing. Which may be what you want, if you can find out what in your app is hiding the keyboard.

Gastelum answered 10/9, 2016 at 13:32 Comment(1)
Not sure why, but not working for me. Having same kind of layout <relativelayout><edittext with bottom true/><recyclerview with above edittext/></relativelayout>Breunig

© 2022 - 2024 — McMap. All rights reserved.