4

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:

nukeforum
  • 1,284
  • 3
  • 16
  • 38
  • 1
    AdjustPan only promises the cursor will be in view, not the entire edit text. There is no fix to this, its working as intended and there is no way to change how it works. – Gabe Sechan Dec 07 '17 at 19:27
  • @nukeforum found anything? – iCantC Jan 28 '20 at 10:31
  • 1
    @iCantC One of the more common answers can be found https://www.davidwparker.com/2011/08/25/android-fixing-window-resize-and-scrolling/ or https://stackoverflow.com/a/3521781. Essentially, wrapping your layout to be scrollable allows the layout to adjust just slightly to display correctly. – nukeforum Jan 31 '20 at 14:23

1 Answers1

4

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

no_fate
  • 1,625
  • 14
  • 22