0

I have a multi-line editText inside a scrollView follow by a button.

enter image description here

If using adjustPan, the softkeyboard cover up the whole editText, leaving only the first line.

enter image description here

When using adjustResize, even the button shows up which is worst

enter image description here

Here is my xml

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toTopOf="@id/btn_save">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="600dp"
                android:background="@color/LightBlue"/>

            <androidx.appcompat.widget.AppCompatEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Enter text"
                android:inputType="textMultiLine"
                android:singleLine="false"
                android:gravity="top"
                android:minLines="8" />

        </LinearLayout>

    </ScrollView>

    <com.google.android.material.button.MaterialButton
        android:id="@+id/btn_save"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Save"
        android:clickable="false"
        app:backgroundTint="@color/gray_jll"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

What I want (temporarily achived using gravity bottom, but of course we want the text to display on the top using gravity top)

enter image description here

I looked at Android soft keyboard covers EditText field. But I am not using full screen mode. android:isScrollContainer="true" does nothing.

Please tell me what is causing this. Thanks in advance.

BabyishTank
  • 1,329
  • 3
  • 18
  • 39
  • set `minHeight` attribute on the EditText. and set `gravity="bottom"` – Noah Oct 20 '21 at 15:36
  • But setting `minHeight` is not good at all. Because when you do that, it would produce a poor user experience for the user. The way Android handles it should be the best, i think. – Noah Oct 20 '21 at 15:39

0 Answers0