1

I know this question has been asked many times and if I'm doing it again is just because is not exactly the same question. I have already added this to my activity in the Manifest:

android:windowSoftInputMode="stateAlwaysHidden|adjustPan"

And also I have tried using a ScrollView. As a result, the EditText is correctly moving up when the keyboard appears. However, I have noticed that it still covers a part of the TextView. It is not enough to cover the text but it still seems wrong:

enter image description here

The code to add the TextView is pretty normal:

    <LinearLayout
        android:id="@+id/login_layout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="50dp"
        android:gravity="center_vertical"
        android:orientation="vertical">


        <EditText
            android:id="@+id/user"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginTop="100dp"
            android:background="@drawable/edit_text_background"
            android:hint="@string/prompt_email"
            android:inputType="text"
            android:maxLines="1"
            android:textSize="15sp" />

So, do you know a way to keep all the TextView above the keyboard? I have only seen this question once but it was not resolved and the guy was using a Fragment, not an Activity.

Thanks

Jaime Alcántara Arnela
  • 2,062
  • 5
  • 25
  • 56

1 Answers1

0

you can do this :

<androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/constraint"
        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"
        app:layout_constraintBottom_toTopOf="@+id/navigation_text_editor"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">
     <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fillViewport="true"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">
          <EditText
                android:id="@+id/user"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="16dp"
                android:layout_marginEnd="16dp"
                android:background="@color/colorAccent"
                android:hint="email"
                android:inputType="text"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />
    </ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
Nikos T
  • 169
  • 1
  • 5