Как предотвратить изменение размера одного действия при открытии клавиатуры - PullRequest
0 голосов
/ 08 апреля 2020

Я хочу, чтобы размер моей активности не изменялся при открытии клавиатуры.

Я знаю, что могу использовать android:windowSoftInputMode="adjustNothing" в своей папке манифеста для этого, но это изменение применяется ко всем моим действиям.

Как я могу применить это изменение только к одному из моих занятий?

Я пытался добавить android:windowSoftInputMode="adjustNothing" к своей деятельности, но это не сработало.

Ответы [ 2 ]

0 голосов
/ 08 апреля 2020

Попробуйте добавить свой код в onCreate

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

Если вы используете представление с прокруткой, добавьте это

android:isScrollContainer="false"

Надеюсь, это работает для вас ....

0 голосов
/ 08 апреля 2020

Попробуйте этот макет:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:orientation="vertical">

            <TextView
                android:id="@+id/entrytext"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="Please Enter your Google Account"
                android:textAlignment="center"
                android:textSize="18dp"
                android:textStyle="bold" />


            <AutoCompleteTextView
                android:id="@+id/emailtext"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:hint="Email"
                android:inputType="textEmailAddress"
                android:textColorHint="#80000000" />

            <EditText
                android:id="@+id/passwordtext"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:hint="Password"
                android:inputType="textPassword"
                android:textColorHint="#80000000" />

            <Button
                android:id="@+id/enter"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="Enter"
                android:textAllCaps="false" />



        </LinearLayout>
    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>
...