0

I'm playing with TextInputEditText and I'm front face a strange issue. When I edit the content of the first one, let's say the "Nom" field, everything looks good, the keyboard appears and I can see the entered text. Now if I need to enter a text in a text field which is under the keyboard, the Activity pans up so the field is in view, but I can NOT see the text that I'm entering... Please have a look at this video: https://www.digitalblend.fr/android_TextInputEditText_issue.mp4

Moreover please have a look at my actual code :

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".MessageFragment">

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp"
            android:layout_marginTop="30dp"
            android:orientation="vertical">

            <View
                android:layout_width="match_parent"
                android:layout_height="120dp" />

            <LinearLayout
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:layout_marginTop="20dp"
                android:orientation="horizontal">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="vertical" >

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:textColor="@color/black"
                        android:textStyle="bold"
                        android:text="@string/required_last_name"/>

                    <com.google.android.material.textfield.TextInputLayout
                        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <com.google.android.material.textfield.TextInputEditText
                            android:id="@+id/lastname"
                            android:layout_width="match_parent"
                            android:padding="5dp"
                            android:maxLines="1"
                            android:hint=""
                            android:inputType="textPersonName"
                            android:nextFocusDown="@+id/firstname"
                            android:layout_height="wrap_content"/>
                    </com.google.android.material.textfield.TextInputLayout>
                </LinearLayout>

                <View
                    android:layout_width="10dp"
                    android:layout_height="0dp"/>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:textColor="@color/black"
                        android:textStyle="bold"
                        android:text="@string/first_name"/>

                    <com.google.android.material.textfield.TextInputLayout
                        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <com.google.android.material.textfield.TextInputEditText
                            android:id="@+id/firstname"
                            android:layout_width="match_parent"
                            android:padding="5dp"
                            android:hint=""
                            android:maxLines="1"
                            android:inputType="textPersonName"
                            app:textInputLayoutFocusedRectEnabled="true"
                            android:layout_height="wrap_content"/>
                    </com.google.android.material.textfield.TextInputLayout>
                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textColor="@color/black"
                    android:textStyle="bold"
                    android:text="@string/required_mail"/>

                <com.google.android.material.textfield.TextInputLayout
                    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/email"
                        android:layout_width="match_parent"
                        android:padding="5dp"
                        android:hint=""
                        android:maxLines="1"
                        android:inputType="textEmailAddress"
                        android:layout_height="wrap_content"/>
                </com.google.android.material.textfield.TextInputLayout>
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textColor="@color/black"
                    android:textStyle="bold"
                    android:text="@string/required_enterprise"/>

                <com.google.android.material.textfield.TextInputLayout
                    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/enterprise"
                        android:layout_width="match_parent"
                        android:padding="5dp"
                        android:maxLines="1"
                        android:hint=""
                        android:inputType="text"
                        android:layout_height="wrap_content"/>
                </com.google.android.material.textfield.TextInputLayout>
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textColor="@color/black"
                    android:textStyle="bold"
                    android:text="@string/required_code_postal"/>

                <com.google.android.material.textfield.TextInputLayout
                    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/postal_code"
                        android:layout_width="match_parent"
                        android:padding="5dp"
                        android:maxLines="1"
                        android:hint=""
                        android:inputType="text"
                        android:layout_height="wrap_content"/>
                </com.google.android.material.textfield.TextInputLayout>
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textColor="@color/black"
                    android:textStyle="bold"
                    android:text="@string/city"/>

                <com.google.android.material.textfield.TextInputLayout
                    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/city"
                        android:layout_width="match_parent"
                        android:padding="5dp"
                        android:maxLines="1"
                        android:hint=""
                        android:inputType="text"
                        android:layout_height="wrap_content"/>
                </com.google.android.material.textfield.TextInputLayout>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/phone_number_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textColor="@color/black"
                    android:textStyle="bold"
                    android:text="@string/required_tel"/>

                <com.google.android.material.textfield.TextInputLayout
                    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                    android:layout_width="match_parent"
                    android:background="@android:color/transparent"
                    android:layout_height="wrap_content">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/phone_number"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:paddingVertical="5dp"
                        android:paddingHorizontal="15dp"
                        android:maxLines="1"
                        android:inputType="text"
                        android:textColor="@color/black"
                        android:imeOptions="actionDone"/>

                </com.google.android.material.textfield.TextInputLayout>
            </LinearLayout>
        </LinearLayout>

        <androidx.appcompat.widget.AppCompatButton
            android:id="@+id/btn_buy"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:scaleType="fitCenter"
            android:background="@drawable/little_red_button"
            android:layout_marginStart="15dp"
            android:layout_marginEnd="15dp"
            android:layout_marginTop="20dp"
            android:text="@string/send_demand"
            android:gravity="center"
            android:textColor="@color/white"
            android:textSize="14sp"/>

    </LinearLayout>
</ScrollView>

In my manifest I used android:windowSoftInputMode="adjustPan">

If someone has an idea ? Thanks in advance.

cactustictacs
  • 17,935
  • 2
  • 14
  • 25
Silvering
  • 756
  • 1
  • 6
  • 33
  • I've changed your title if you don't mind - I thought you meant the ``EditText`` was still being obscured by the keyboard, it took me a moment to realise the problem in the video. That's a weird one! Are you using the latest version of the ``appcompat`` library (the one ``TextInputEditText`` etc is in)? https://developer.android.com/jetpack/androidx/releases/appcompat – cactustictacs Feb 25 '22 at 16:10
  • @cactustictacs thanks for your response. I checked the appcompat version, I'm using the latest available. – Silvering Feb 28 '22 at 12:32

0 Answers0