当我点击输入一些文本时,我的程序屏幕底部有一个LinearLayout
包含a ,出现键盘并且高度缩小,所以我看不到我写的内容。EditText
EditText
EditText
EditText
我对此进行了搜索,发现可能与AndroidManifest.xml
文件有关。所以我将此行添加到文件中:
android:windowSoftInputMode="adjustPan"
但这在我将此代码添加到清单后EditText
放置在键盘后面后无法正常工作。
最后我想知道有什么办法可以防止在显示键盘时调整视图大小?
我的活动 XML 代码:
<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:layout_height="match_parent"
android:fitsSystemWindows="false">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="10"
app:layout_constraintTop_toTopOf="parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/msgView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
android:background="@drawable/sssaaa">
</android.support.v7.widget.RecyclerView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#80000000"
android:weightSum="10">
<EditText
android:id="@+id/txt_message"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:layout_weight="8.8"
android:background="@drawable/rounded_corner"
android:hint="@string/hint"
android:inputType="text"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#000000" />
<Button
android:id="@+id/btn_send"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_weight="1"
android:background="@drawable/circular_button"
android:textColor="#000000"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>