当软键盘出现时,布局会发生变化

时间:2017-06-20 20:35:58

标签: android android-layout android-linearlayout android-xml

我有两个linearlayout一个低于另一个,如下所示:

<LinearLayout
        android:layout_width="368dp"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center"
        android:id="@+id/linearLayout">

        <ImageView
            android:id="@+id/reg_imageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:srcCompat="@drawable/z"/>

        <TextView
            android:id="@+id/reg_app_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/app_title"
            android:textSize="20sp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="368dp"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="vertical"
        android:layout_marginRight="0dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="0dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="0dp"
        android:layout_marginTop="0dp"
        app:layout_constraintTop_toBottomOf="@+id/linearLayout">

        <EditText
            android:id="@+id/req_number"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:ems="10"
            android:hint="@string/request_number"
            android:inputType="number" />

以下是布局图:

before the soft keyboard

键盘显示时,布局错过了:

when the keyboard shows

导致此问题的原因是什么?

注意:.xml文件中有app:layout_constraintTop_toBottomOf="@+id/linearLayout"行,其中包含EditText,需要(请求编号)

1 个答案:

答案 0 :(得分:2)

  

在此活动的清单中

android:windowSoftInputMode="adjustNothing"