【问题标题】:The layout changes when the soft keyboard appears软键盘出现时布局发生变化
【发布时间】:2017-06-20 20:35:57
【问题描述】:

我有两个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" />

这是布局的图片:

当键盘显示时,布局会丢失:

是什么导致了这个问题?

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

【问题讨论】:

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


【解决方案1】:

在此活动的清单中放置

android:windowSoftInputMode="adjustNothing"

【讨论】:

  • 其实他可能想要adjustPan。他的问题似乎与调整大小有关。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-07
  • 2023-03-24
  • 1970-01-01
  • 2022-12-19
  • 1970-01-01
相关资源
最近更新 更多