键盘隐藏RecyclerView打开时

时间:2017-04-10 17:50:03

标签: android android-recyclerview

我正在尝试使用RecyclerView创建一个Fragment作为聊天应用中的评论部分。在此片段的评论部分上方是其他一些观点。注释部分和片段的根视图都应该是可滚动的。我的问题是,当键盘打开时,它涵盖了评论部分RecyclerView。我希望(希望)在键盘打开时扩展RecyclerView,以便您可以向下滚动以查看注释。

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.

我尝试了很多类似于我在SO上的问题的解决方案,但没有任何效果。

这是我的活动清单声明:

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

这是我的布局:

<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>

0 个答案:

没有答案