Android Studio - EditText 输入移动 TextView

Android Studio - EditText input moves TextView

我在 EditText 下方有一个文本视图。
当我在 EditText 中输入数据时,TextView 向上移动,因此它仍然可见。
我的意思是我输入数据,键盘出现,TextView 也向上移动。
但我不想这样,我希望 TextView 保持原样。
我正在使用 ConstraintLayout 并且我无法将约束设置得更紧,因为如果我按下按钮,TextView 将填充数据。

    <EditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPersonName"
        android:layout_marginTop="50dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        android:hint="@string/hint1"
        android:importantForAutofill="no"/>

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="24dp"
        android:layout_marginBottom="24dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/button"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constrainedHeight="true">

        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/emptyString" />

    </ScrollView>

我认为,您已将文本视图放在滚动视图中,这就是它以这种方式运行的原因。

我找到了解决方案,它是在起始 activity 标记中添加这一行: android:windowSoftInputMode="adjustPan"

像这样:

<activity android:name=".MainActivity"
            android:windowSoftInputMode="adjustPan">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

现在,当键盘出现时,TextView 不再移动。
它被键盘覆盖,但我更喜欢这样而不是移动视图。