У меня есть макет с ConstraintLayout как root, и этот макет принадлежит фрагменту, показанному в ViewPager2, размещенному в Activity, который расширяет FragmentActivity. Моя проблема в том, что каждый раз, когда клавиатура поднята, она не перекрывает макет, а уменьшает размер окна, изменяя аспект моего макета.
Макет ViewPager:
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.WelcomeActivity">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="20dp"
app:layout_constraintGuide_percent=".5" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/welcome_viewPager2"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<me.relex.circleindicator.CircleIndicator3
android:id="@+id/welcome_indicator"
android:layout_width="match_parent"
android:layout_height="48dp"
app:layout_constraintBottom_toTopOf="@+id/view5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<View
android:id="@+id/view5"
android:layout_width="1dp"
android:layout_height="0dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:background="@android:color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/welcome_btnLogar" />
<Button
android:id="@+id/welcome_btnLogar"
style="?android:buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/transparentBlack"
android:text="@string/login"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="@android:color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/view5"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/welcome_btnRegister"
style="?android:buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/transparentBlack"
android:text="@string/create_an_account"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="@android:color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/view5" />
Макет фрагмента :
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.CadastroActivity">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/cadastro_frag1_inputLayout_ame"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:hint="@string/name"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.25"
app:startIconDrawable="@drawable/ic_android_gray_24dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/cadastro_frag1_inputEdit_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/cadastro_frag1_inputLayout_email"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:hint="@string/email"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cadastro_frag1_inputLayout_ame"
app:startIconDrawable="@drawable/ic_email_gray_24dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/cadastro_frag1_inputEdit_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/cadastro_frag1_inputLayout_password"
android:layout_width="0dp"
app:startIconDrawable="@drawable/ic_lock_open_gray_24dp"
android:layout_height="wrap_content"
app:helperText="@string/min_6_characters"
app:helperTextTextColor="@color/colorAccentWelcome"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
app:counterEnabled="true"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:hint="@string/password"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cadastro_frag1_inputLayout_email"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/cadastro_frag1_inputEdit_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/cadastro_frag1_inputLayout_confirmPassword"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
app:counterEnabled="true"
android:layout_marginRight="8dp"
android:hint="@string/confirm_your_password"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cadastro_frag1_inputLayout_password"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/cadastro_frag1_inputEdit_confirmPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="@+id/cadastro_frag1_btnNextStep"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginLeft="32dp"
android:layout_marginEnd="32dp"
android:layout_marginRight="32dp"
android:textColor="@android:color/white"
android:text="@string/go_to_next_step"
android:background="@drawable/shape_btn_all_round_welcome_accent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cadastro_frag1_inputLayout_confirmPassword" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-condensed-medium"
android:text="@string/step_1_2"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:textColor="@color/colorAccentWelcome"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/cadastro_frag1_inputLayout_ame"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Как сделать так, чтобы клавиатура перекрывала раскладку?