Search code examples
androidandroid-layoutandroid-linearlayoutandroid-xml

The layout changes when the soft keyboard appears


I have two linearlayout one is below the other as below:

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

Here is the picture of the layout:

before the soft keyboard

when the keyboard shows, the layout get missed up:

when the keyboard shows

What is causing this issue?

NOTE: I have app:layout_constraintTop_toBottomOf="@+id/linearLayout" line in the .xml file that holds the EditText that requires the (Request number)


Solution

  • in manifest for this activity put

    android:windowSoftInputMode="adjustNothing"