我在SO中给出了这么多答案,但仍然没有结果。我有这个xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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:background="#f3f3f3"
android:layout_height="match_parent">
<include layout="@layout/headerVw"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:id="@+id/headerVw"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/rvChatList"
android:layout_width="0dp"
android:layout_height="0dp"
android:paddingBottom="@dimen/dimen_10dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@+id/divider_vw">
</android.support.v7.widget.RecyclerView>
<!-- A horizontal line between the chatbox and RecyclerView -->
<View
android:id="@+id/divider_vw"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="#c7c7c7"
android:layout_marginBottom="0dp"
app:layout_constraintBottom_toTopOf="@+id/bottomLayout"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<LinearLayout
android:id="@+id/bottomLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:minHeight="48dp"
android:background="#ffffff"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent">
<LinearLayout
android:id="@+id/servicesLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/rvServicesList"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#c7c7c7"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/ivUpArrow"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_uparrow"
android:layout_gravity="bottom" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#c7c7c7"
android:layout_margin="@dimen/dimen_5dp"/>
<EditText
android:id="@+id/edittext"
android:hint="@string/hi_how_can_i_help_you"
android:background="@android:color/transparent"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_width="0dp"
android:layout_weight="1"
android:textSize="@dimen/textSize_12sp"
android:layout_height="wrap_content"
android:maxLines="6"/>
<ImageView
android:id="@+id/btnSend"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="@dimen/dimen_10dp"
android:src="@drawable/ic_send_icon"
android:layout_gravity="bottom" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#c7c7c7"
android:layout_margin="@dimen/dimen_5dp"/>
<ImageView
android:id="@+id/ivMic"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:layout_width="48dp"
android:layout_height="48dp"
android:padding="@dimen/dimen_10dp"
android:src="@drawable/ic_mic_grey"
android:layout_gravity="bottom" />
</LinearLayout>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
这里我希望headerVw固定在顶部,而当edittext接收焦点并显示键盘时,回收站视图和bottomLayout向上移动。但是在给定xml的情况下,bottomLayout在键盘后面隐藏了一半,并且headerVw也正在滚动并隐藏当键盘处于打开状态时。 提前致谢!