Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adjustPan cuts off bottom of EditText

Tags:

android

It appears that adjustPan is actually panning on the baseline of my EditText rather than the actual edge of the view.

Bottom edge covered

I've been searching for a way to fix this, but I just haven't been able to find anything.

Activity code (kotlin):

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    window.setSoftInputMode(SOFT_INPUT_ADJUST_PAN)
}

Layout xml:

<android.support.constraint.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="com.foo.testbed.MainActivity">

<EditText
    android:id="@+id/myEditText"
    android:layout_width="0dp"
    android:layout_height="48dp"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="15dp"
    android:layout_marginStart="8dp"
    android:background="@drawable/rounded_edit_text"
    android:hint="Message"
    android:paddingStart="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toStartOf="@id/myButton"
    app:layout_constraintStart_toStartOf="parent" />

<Button
    android:id="@+id/myButton"
    android:layout_width="wrap_content"
    android:layout_height="48dp"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:text="Send"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="@id/myEditText" />

I have attempted solutions from the following questions to no avail:

  • adjustPan not preventing keyboard from covering EditText
  • AdjustPan with EditText at Bottom of Layout Causes SoftKeyboard to Slightly Obscure EditText View
like image 535
nukeforum Avatar asked Sep 17 '25 06:09

nukeforum


1 Answers

Solution is to set a top&bot paddings

My example with editText:

<AutoCompleteTextView
                android:id="@+id/editText_new_password"
                android:layout_width="match_parent"
                android:layout_height="@dimen/btn_editbox_height"
                android:background="@drawable/edit_text_style"
                android:gravity="center_vertical"
                android:paddingEnd="@dimen/login_edit_box_pass_padding_right"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:paddingStart="@dimen/edit_box_padding"
                android:textSize="14sp" />

enter image description here

with paddings 12:

enter image description here

and naked paddings:

enter image description here

like image 196
no_fate Avatar answered Sep 19 '25 20:09

no_fate