我在CoordinatorLayout中使用了RecyclerView,就像这样
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:gravity="center_vertical">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/txtLayoutInvestment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp">
<android.support.design.widget.TextInputEditText
android:id="@+id/investmentAmount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/inputProjectInvestmentHint"
android:inputType="number"/>
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/loanList"
android:textSize="20sp"/>
<ImageButton
android:id="@+id/btAddLoan"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:src="@android:drawable/ic_input_add"/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/loanList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_marginBottom="16dp"
android:focusable="false"
android:gravity="center_horizontal|bottom">
<Button
android:id="@+id/btBack"
style="?android:borderlessButtonStyle"
android:layout_width="80dp"
android:layout_height="48dp"
android:layout_marginEnd="8dp"
android:text="@string/back_button"
android:textColor="@color/colorAccent"/>
<Button
android:id="@+id/btCancel"
style="?android:borderlessButtonStyle"
android:layout_width="80dp"
android:layout_height="48dp"
android:layout_marginEnd="8dp"
android:text="@string/cancel_button"
android:textColor="@color/colorAccent"/>
<Button
android:id="@+id/btNext"
style="?android:borderlessButtonStyle"
android:layout_width="80dp"
android:layout_height="48dp"
android:layout_marginEnd="8dp"
android:text="@string/next_button"
android:textColor="@color/colorAccent"/>
</LinearLayout>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
一切正常,直到我在editText上方输入内容并在键盘上触摸
我猜这是由协调器布局或recyclerview行为的配置引起的,但我不知道要修复它。请帮忙
* 170418更新:如果在按下主页按钮后返回应用程序,则显示正常。