-1

I am quite new in Android UI design so please bear with me. In a relative layout I have a number of different controls -- TextView, ET, Button etc, and at the bottom part a ListView is populated. On the load of the activity when the focus is going to the first input field (Edit Text) the keypad pushes up the ListView and it overlaps the other fields.

Below is the layout xml:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout 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"
    android:background="@android:color/holo_orange_light"
    tools:context="com.as.myexpense.AddExpenseAct"
    tools:layout_editor_absoluteX="0dp"
    tools:layout_editor_absoluteY="81dp">

    <TextView
   android:id="@+id/tvShowExpnDate"
    android:layout_width="385dp"
    android:layout_height="19dp"
    android:allowUndo="true"
    android:autoSizeTextType="uniform"
    android:background="@color/colorAccent"
    android:fontFamily="sans-serif"
    android:foregroundTintMode="src_over"
    android:text="Expense for the date"
    android:textColor="@android:color/background_dark"
    android:textSize="12sp"
    android:textStyle="bold"
    tools:ignore="HardcodedText,MissingConstraints,RtlHardcoded,UnusedAttribute"
    tools:layout_editor_absoluteX="16dp"
    tools:layout_editor_absoluteY="7dp" />

    <TextView
    android:id="@+id/txtChangeExpenseDate"
    android:layout_width="88dp"
    android:layout_height="17dp"
    android:background="@android:color/holo_green_light"
    android:text="Change Date"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/tvShowExpnDate"
    tools:ignore="HardcodedText,MissingConstraints,RtlHardcoded"
    android:layout_below="@+id/tvShowExpnDate"
    android:layout_alignStart="@+id/etExpenseAmount" />

    <TextView
    android:id="@+id/tvAmount"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignStart="@+id/imgCategory"
    android:layout_below="@+id/txtChangeExpenseDate"
    android:text="Amount"
    android:textSize="20sp"
    app:layout_constraintTop_toBottomOf="@+id/tvShowExpnDate"
    tools:layout_editor_absoluteX="48dp" />

    <TextView
    android:id="@+id/tvExpenseCategory"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignStart="@+id/imgCategory"
    android:layout_below="@+id/etExpenseAmount"
    android:text="Choose category"
    android:textSize="20sp"
    app:layout_constraintTop_toBottomOf="@+id/tvAmount"
    tools:ignore="HardcodedText,MissingConstraints"
    tools:layout_editor_absoluteX="48dp" />

    <EditText
    android:id="@+id/etExpenseAmount"
    android:layout_width="125dp"
    android:layout_height="40dp"
    android:ems="8"
    android:inputType="numberDecimal"
    android:labelFor="@+id/etExpenseAmount"
    app:layout_constraintLeft_toRightOf="@+id/tvAmount"
    app:layout_constraintTop_toBottomOf="@+id/tvShowExpnDate"
    app:srcCompat="@android:color/holo_orange_light"
    android:layout_alignTop="@+id/tvAmount"
    android:layout_toEndOf="@+id/imgCategory"
    android:layout_marginStart="12dp" />

    <ImageButton
    android:id="@+id/imgCategory"
    android:layout_width="75dp"
    android:layout_height="75dp"
    android:layout_alignStart="@+id/tvTotalExpense"
    android:layout_below="@+id/tvExpenseCategory"
    android:adjustViewBounds="true"
    android:scaleType="fitXY"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/tvExpenseCategory"
    app:srcCompat="@android:color/holo_orange_light"
    tools:ignore="ContentDescription" />

    <EditText
    android:id="@+id/etShortDescription"
    android:layout_width="200dp"
    android:layout_height="39dp"
    android:layout_above="@+id/btnAddExpnToList"
    android:layout_marginBottom="10dp"
    android:layout_toEndOf="@+id/tvExpenseCategory"
    android:autoText="true"
    android:ems="10"
    android:hint="@string/short_description"
    android:inputType="textPersonName"
    android:maxLines="1"
    app:layout_constraintLeft_toRightOf="@+id/imgCategory"
    app:layout_constraintTop_toTopOf="parent"
    tools:ignore="Deprecated,LabelFor" />

    <Button
    android:id="@+id/btnAddExpnToList"
    android:layout_width="118dp"
    android:layout_height="50dp"
    android:layout_alignBottom="@+id/floatingActionButton"
    android:layout_alignParentStart="true"
    android:text="@string/Add"
    android:textColor="@android:color/background_dark"
    app:layout_constraintLeft_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/etShortDescription" />

    <Button
    android:id="@+id/btnCancel"
    android:layout_width="118dp"
    android:layout_height="50dp"
    android:layout_below="@+id/etShortDescription"
    android:layout_marginStart="17dp"
    android:layout_toEndOf="@+id/btnAddExpnToList"
    android:text="@string/Cancel"
    android:textColor="@android:color/background_dark"
    android:visibility="invisible"
    app:layout_constraintLeft_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/etShortDescription" />

    <ListView
    android:id="@+id/lvExpenses"
    android:layout_width="387dp"
    android:layout_height="312dp"
    android:layout_alignParentBottom="true"
    android:layout_alignStart="@+id/tvTotalExpense"
    android:layout_marginBottom="5dp"
    android:layout_marginTop="5dp"
    android:background="?attr/colorButtonNormal"
    app:layout_constraintLeft_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/btnAddExpnToList" />

    <TextView
    android:id="@+id/tvTotalExpense"
    android:layout_width="288dp"
    android:layout_height="20dp"
    android:layout_above="@+id/lvExpenses"
    android:layout_marginStart="10dp"
    android:text="Total expense "
    android:visibility="invisible"
    app:layout_constraintLeft_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/btnAddExpnToList"
    tools:ignore="HardcodedText" />

    <android.support.design.widget.FloatingActionButton
    android:id="@+id/floatingActionButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/tvTotalExpense"
    android:layout_alignEnd="@+id/etShortDescription"
    android:layout_marginBottom="6dp"
    android:clickable="true"
    android:focusable="true"
    app:srcCompat="@android:color/holo_orange_dark" />

    <TextView
    android:id="@+id/tvExpnCatDisplay"
    android:layout_width="90dp"
    android:layout_height="20dp"
    android:layout_above="@+id/btnAddExpnToList"
    android:layout_alignStart="@+id/imgCategory"
    android:background="#00000000"
    android:textColor="@color/common_google_signin_btn_text_dark_focused"
    android:textSize="18sp"
    android:textStyle="normal|bold" />

    <TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignStart="@+id/spTxnType"
    android:layout_below="@+id/tvShowExpnDate"
    android:layout_marginTop="9dp"
    android:text="@string/payment_type"
    android:textSize="18sp" />

    <Spinner
    android:id="@+id/spTxnType"
    android:layout_width="120dp"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView3"
    android:layout_toEndOf="@+id/btnCancel"
    android:entries="@array/txnType_name"
    android:spinnerMode="dialog"
    android:theme="@style/AlertDialog.AppCompat" />
    </RelativeLayout>

Below are the screenshots:

On load of the screen

Expected view

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

0

"adjustResize"

The activity's main window is always resized to make room for the soft keyboard on screen.

"adjustPan"

The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.

according to your comment, use following in your activity manifest

  • Thank you for the explanation. Yes I tried the settings in manifest and that resolved the issue. For me both adjustPan and adjustNothing is serving the purpose. But when with adjustPan when the arrow key inthe soft keyboard is pressed the issue reappears.So I used adjustNothing and that seems to resolve the issue completely. Note: I used a android Kitkat mobile for testing. Thanks for your comment. – Abhijit Sarkar Dec 16 '17 at 16:17