Andrej Vilenskij
Andrej Vilenskij

Reputation: 517

AndroidStudio - TextInput hide characters when keyboard shows up

When I try to enter characters in my TextInputEdit I can't see them while keyboard is shown up. enter image description here

It happens only with the last textinputedit in my activity, other works perfectly. When I hide my keyboard - characters appears, but when I try to add some again I cant see any changes until keyboard hides.

My xml of activity:

<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Registration"
android:id="@+id/app_bar">

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/regEmailwrapper"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="16dp"
    app:layout_constraintTop_toTopOf="parent"
    tools:layout_editor_absoluteX="0dp">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/regEmail"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:hint="Your Email *"
        android:inputType="textEmailAddress" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/regNamewrapper"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="16dp"
    app:layout_constraintTop_toBottomOf="@+id/regEmailwrapper"
    tools:layout_editor_absoluteX="0dp">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/regName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:hint="First name" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/regSurnameWrapper"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="16dp"
    app:layout_constraintTop_toBottomOf="@+id/regNamewrapper"
    tools:layout_editor_absoluteX="0dp">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/regSurname"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:hint="Last name" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/regPasswordwrapper"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="16dp"
    app:layout_constraintTop_toBottomOf="@+id/regSurnameWrapper"
    tools:layout_editor_absoluteX="0dp">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/regPassword"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:hint="Password *"
        android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/regPassword2wrapper"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="16dp"
    app:layout_constraintTop_toBottomOf="@+id/regPasswordwrapper"
    tools:layout_editor_absoluteX="0dp">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/regPassword2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:hint="Password again *"
        android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>

<Button
    android:id="@+id/signUp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="16dp"
    android:text="Sign up!"
    app:layout_constraintTop_toBottomOf="@+id/genderDropdown"
    tools:layout_editor_absoluteX="0dp" />

<Spinner
    android:id="@+id/genderDropdown"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="16dp"
    android:spinnerMode="dropdown"
    app:layout_constraintTop_toBottomOf="@+id/regPassword2wrapper"
    tools:layout_editor_absoluteX="0dp" />

</androidx.constraintlayout.widget.ConstraintLayout>

How can i fix it?

Upvotes: 0

Views: 248

Answers (2)

SkypeDogg
SkypeDogg

Reputation: 1040

You can wrap your ConstraintLayout inside ScrollView so you can easily scroll view when you can't see TextInput

<ScrollView 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"
    android:fillViewport="true">

This should be enough. I think there's no need to add anything inside Manifest

Upvotes: 1

Vinay Jayaram
Vinay Jayaram

Reputation: 1005

Add this properties :

 android:windowSoftInputMode="adjustPan|adjustResize" 

to your Activity tag in AndroidManifest.xml

Upvotes: 2

Related Questions