Soft Keboard скрывает TextInputEditText внутри действия фрагмента - PullRequest
0 голосов
/ 08 июня 2019

У меня есть фрагмент с 2 TextInputEditText. Когда моя деятельность начинается, программная клавиатура закрывает часть моего ввода, и при нажатии кнопки NEXT на клавиатуре фокус переходит ко второму входу, который полностью покрыт клавиатурой. То, что было напечатано, можно увидеть только при закрытии клавиатуры.

enter image description here

Это мой макет:

<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat 
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"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/back_gradient"
android:orientation="vertical"
android:padding="@dimen/DP10"
tools:context=".activities.MainActivity">

<TextView
    android:id="@+id/tv_new_course_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="@dimen/SP22"
    android:layout_marginBottom="150dp"
    android:text="@string/newCourse"
    android:textColor="@color/colorPrimary"
    android:textSize="@dimen/SP26"
    android:textStyle="bold"/>


<com.google.android.material.textfield.TextInputLayout
    style="@style/LoginTextInputLayoutStyle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="@dimen/DP20"
    android:layout_marginRight="@dimen/DP20"
    android:hint="@string/courseName">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/et_new_course_name"
        style="@style/LoginTextInputEditStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textEmailAddress"
        android:nextFocusDown="@+id/et_new_course_acronym"
        />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
    style="@style/LoginTextInputLayoutStyle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="@dimen/DP20"
    android:layout_marginRight="@dimen/DP20"
    android:hint="@string/acronym">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/et_new_course_acronym"
        style="@style/LoginTextInputEditStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textEmailAddress" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.button.MaterialButton
    android:id="@+id/btn_save_course"
    style="@style/Widget.MaterialComponents.Button.OutlinedButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="@dimen/DP40"
    android:layout_marginBottom="@dimen/DP10"
    android:text="@string/save"
    android:textColor="@color/color_ok"
    app:cornerRadius="@dimen/DP15"
    app:strokeColor="@color/color_ok"
    app:strokeWidth="@dimen/DP2" />

Тот же макет отлично работает, если он накачан на активность, но здесь это фрагмент.

Ответы [ 2 ]

2 голосов
/ 08 июня 2019

Существует несколько способов устранения проблемы:

Процесс 1

Используйте ScrollView в качестве корневого макета и поместите в него все остальные макеты.

Процесс 2 (рекомендуется)

Используйте android:windowSoftInputMode="adjustPan|adjustResize" в файле манифеста.Более подробно об этом здесь.

1 голос
/ 08 июня 2019

, пожалуйста, добавьте это в свой атрибут активности в манифесте

<activity android:name="Your_Activity" android:windowSoftInputMode="adjustPan" ></activity>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...