Reputation: 63
In a Bottom Navigation Activity I've a Fragment with a button, an EditText and a TextView.
The problem is that when I focus the EditText to write with the keyboard it moves up and the button bugs in it. How can I solve?
<?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"
<TextView
android:layout_width="0dp"
android:layout_height="178dp"
android:gravity="start|top"
android:ems="10"
android:id="@+id/output"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toBottomOf="parent"
android:autofillHints="" app:layout_constraintVertical_bias="0.386"
app:layout_constraintTop_toBottomOf="@+id/button" app:layout_constraintHorizontal_bias="0.666"
style="@style/Widget.AppCompat.TextView" android:scrollbars="vertical" android:textSize="18sp"
/>
<EditText
android:layout_width="0dp"
android:layout_height="178dp"
android:inputType="textMultiLine"
android:gravity="start|top"
android:ems="10"
android:id="@+id/input"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.666"
android:autofillHints="" android:hint="@string/hint" android:layout_marginTop="16dp"
app:layout_constraintBottom_toTopOf="@+id/button" app:layout_constraintVertical_bias="0.574"
android:scrollbars="vertical"/>
<Button
android:text="@string/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/button"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintHorizontal_bias="0.498" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Upvotes: 2
Views: 3211
Reputation: 883
it work for me ,it grateful ,try it
android:windowSoftInputMode="adjustPan"
Upvotes: 0
Reputation: 316
Use this
' android:windowSoftInputMode="adjustPan" '
in AndroidMenifest.xml file
<activity
android:name=".ui.activity.approve_pending.ApprovalsActivity"
android:windowSoftInputMode="adjustPan" />
You will find more information here https://developer.android.com/training/keyboard-input/visibility
Upvotes: 7
Reputation: 8518
Your constraints are probably what's causing this behavior.
Try removing the bottom constraint on your EditText, and setting the top constraint on your button to the bottom of the EditText instead of the top of the parent. I believe that will fix it.
Upvotes: 0