1

I am trying to create a Fragment with a RecyclerView as a comments section in my chat app. Above the comments section in this Fragment are some other views. Both the comments sections and the fragment's root view should be scrollable. My issue is that when the keyboard is opened, it covers the comments section RecyclerView. I would expect (desire) to have the RecyclerView expand when the keyboard is opened such that you can scroll down to see the comments.

This is what the Fragment looks like prior to opening the keyboard. You can scroll through the comments without scrolling the whole Fragment.

This is what the Fragment looks like after opening the keyboard. You cannot scroll the Fragment down to see the comments section. I would expect to be able to scroll the Fragment down to expose the comments section, which one could then scroll through.

I have tried many solutions that seem similar to my issue on SO but nothing has worked.

This is my activity manifest declaration:

<activity
        android:name=".ui.notes.NoteDetailActivity"
        android:configChanges="orientation|screenSize"
        android:windowSoftInputMode="adjustResize" />

And this is my layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/fl_chat_box_container"
        android:fillViewport="true">

        <android.support.constraint.ConstraintLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <com.sleck.android.ui.view.AvatarView
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_marginLeft="8dp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                android:layout_marginTop="8dp"
                android:id="@+id/av_producer"
                android:layout_marginStart="8dp"
                app:corner_radius="25dp"
                android:src="@drawable/empty_avatar"/>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                app:layout_constraintLeft_toRightOf="@+id/av_producer"
                android:layout_marginLeft="8dp"
                android:layout_marginStart="8dp"
                app:layout_constraintTop_toTopOf="@+id/av_producer"
                android:layout_marginTop="8dp"
                app:layout_constraintBottom_toBottomOf="@+id/av_producer"
                android:layout_marginBottom="8dp">

                <TextView
                    android:id="@+id/tv_producer_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="TextView"
                    android:textSize="16sp" />

                <TextView
                    android:id="@+id/tv_last_modified"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="TextView"
                    android:textColor="@color/grey3"
                    android:textStyle="bold" />
            </LinearLayout>

            <View
                android:id="@+id/view"
                android:layout_width="0dp"
                android:layout_height="1dp"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginTop="8dp"
                android:background="@color/divider_dark"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/av_producer" />

            <View
                android:id="@+id/v_assignee_divider"
                android:layout_width="0dp"
                android:layout_height="1dp"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginTop="8dp"
                android:background="@color/divider_dark"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/tv_assignee" />

            <TextView
                android:id="@+id/tv_assignee"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:text="TextView"
                app:layout_constraintTop_toBottomOf="@+id/view"
                android:layout_marginRight="8dp"
                app:layout_constraintRight_toRightOf="parent"
                android:layout_marginLeft="8dp"
                app:layout_constraintLeft_toLeftOf="parent"
                android:layout_marginStart="8dp"
                android:layout_marginEnd="8dp" />

            <EditText
                android:id="@+id/et_title"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginTop="4dp"
                android:layout_marginBottom="4dp"
                android:inputType="text"
                android:hint="@string/title"
                android:background="@null"
                android:textSize="22sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/v_assignee_divider" />

            <View
                android:id="@+id/v_title_divider"
                android:layout_width="0dp"
                android:layout_height="1dp"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginTop="8dp"
                android:background="@color/divider_dark"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/et_title" />

            <FrameLayout
                android:id="@+id/fl_toolbar_container"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/v_title_divider">

                <include
                    android:id="@+id/rte_toolbar_container"
                    layout="@layout/rte_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />

            </FrameLayout>

            <FrameLayout
                android:id="@+id/fl_et_container"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:minHeight="100dp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/fl_toolbar_container">

                <com.onegravity.rteditor.RTEditText
                    android:id="@+id/rtEditText"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="8dp"
                    android:layout_marginRight="8dp"
                    android:layout_marginTop="8dp"
                    android:background="@null"
                    android:backgroundTint="@color/primary_color"
                    android:textCursorDrawable="@null" />

            </FrameLayout>

            <View
                android:id="@+id/view3"
                android:layout_width="0dp"
                android:layout_height="1dp"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginTop="8dp"
                android:background="@color/divider_dark"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/fl_et_container" />

            <HorizontalScrollView
                android:id="@+id/horizontalScrollView2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:layout_marginTop="8dp"
                android:fillViewport="true"
                app:layout_constraintLeft_toRightOf="@+id/imageView2"
                app:layout_constraintTop_toBottomOf="@+id/view3"
                android:layout_marginStart="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginRight="8dp"
                app:layout_constraintRight_toRightOf="parent">

                <com.sleck.android.ui.base.AttachmentCompleteTextView
                    android:id="@+id/actv_attachments"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:background="@null"
                    android:cursorVisible="false"/>

            </HorizontalScrollView>


            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="28dp"
                android:layout_height="28dp"
                android:layout_marginLeft="8dp"
                app:layout_constraintBottom_toBottomOf="@+id/horizontalScrollView2"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="@+id/horizontalScrollView2"
                app:layout_constraintVertical_bias="0.0"
                app:srcCompat="@drawable/ic_notedetailfiles"
                android:layout_marginStart="8dp" />

            <HorizontalScrollView
                android:id="@+id/horizontalScrollView3"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginEnd="8dp"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="8dp"
                android:fillViewport="true"
                app:layout_constraintLeft_toRightOf="@+id/imageView4"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/horizontalScrollView2">

                <com.sleck.android.ui.base.TagCompleteTextView
                    android:id="@+id/tctv_tags"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:background="@null" />

            </HorizontalScrollView>

            <ImageView
                android:id="@+id/imageView4"
                android:layout_width="28dp"
                android:layout_height="28dp"
                android:layout_marginLeft="8dp"
                app:layout_constraintBottom_toBottomOf="@+id/horizontalScrollView3"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="@+id/horizontalScrollView3"
                app:srcCompat="@drawable/ic_notedetailtags"
                android:layout_marginStart="8dp" />

            <View
                android:id="@+id/view4"
                android:layout_width="0dp"
                android:layout_height="1dp"
                android:layout_marginLeft="0dp"
                android:layout_marginRight="0dp"
                android:layout_marginTop="8dp"
                android:background="@color/divider_dark"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/horizontalScrollView3" />

            <!--<ProgressBar-->
                <!--android:id="@+id/progressBar"-->
                <!--style="?android:attr/progressBarStyle"-->
                <!--android:layout_width="wrap_content"-->
                <!--android:layout_height="wrap_content"-->
                <!--android:layout_marginTop="8dp"-->
                <!--android:layout_marginRight="8dp"-->
                <!--android:layout_marginLeft="8dp"-->
                <!--app:layout_constraintTop_toBottomOf="@+id/view4"-->
                <!--app:layout_constraintRight_toRightOf="parent"-->
                <!--app:layout_constraintLeft_toLeftOf="parent"/>-->

            <android.support.v7.widget.RecyclerView
                android:id="@+id/rv_activities"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_marginLeft="0dp"
                android:layout_marginRight="0dp"
                android:background="@color/chat_background"
                android:paddingTop="4dp"
                app:layout_constraintHeight_min="400dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/view4">

            </android.support.v7.widget.RecyclerView>

        </android.support.constraint.ConstraintLayout>

    </ScrollView>

    <FrameLayout
        android:id="@+id/fl_chat_box_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true">

        <include layout="@layout/note_comments_chat_box"/>

    </FrameLayout>

</RelativeLayout>
  • here is an example for your answer [Adjust Resize in scroolvie](http://stackoverflow.com/questions/2150078/how-to-check-visibility-of-software-keyboard-in-android/4737265#4737265) – Umut Aksun Apr 10 '17 at 17:57

0 Answers0