1

I have a Fragment that contains a ListView to which I add three EditText's to and one Spinner when I select the second EditText the keyboard shows as expected but I cannot scroll the list view to the last two remaining elements in the list view while the keyboard is visible.

It's almost as though the list view is not recognizing that the soft-keyboard is visible the last two remaining elements are still behind the soft-keyboard.

Below is screenshots and XML of the views in question.

AndroidManifest:

<activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:windowSoftInputMode="adjustPan">

List view:

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity$PlaceholderFragment"
android:background="@color/generic_grey">

<ListView
    android:id="@+id/form_base_listview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:divider="@null"
    android:dividerHeight="0dp"
    android:descendantFocusability="afterDescendants"
    />
</RelativeLayout>

Multiline View:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:paddingBottom="5dp">

<TextView
    android:id="@+id/form_multi_txt"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/testing"
    android:padding="10dp"/>

<EditText
    android:id="@+id/form_multi_edit"
    android:layout_width="fill_parent"
    android:layout_height="100dp"
    android:layout_below="@+id/form_multi_txt"
    android:layout_marginLeft="5dp"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:background="@drawable/edit_text_background"
    android:layout_toLeftOf="@+id/form_multi_info_btn"
    android:layout_toStartOf="@+id/form_multi_info_btn"
    android:inputType="textMultiLine"/>

<ImageButton
    android:id="@+id/form_multi_info_btn"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:scaleType="fitStart"
    android:src="@drawable/form_row_info"
    android:background="@android:color/transparent"
    android:layout_below="@+id/form_multi_txt"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"/>

</RelativeLayout>

Spinner:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:paddingBottom="5dp">

<TextView
    android:id="@+id/form_select_txt"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/testing"
    android:padding="10dp"/>

<Spinner
    android:id="@+id/form_select_spinner"
    android:layout_width="fill_parent"
    android:layout_height="44dp"
    android:layout_below="@+id/form_select_txt"
    android:layout_marginLeft="5dp"
    android:spinnerMode="dialog"
    android:layout_toLeftOf="@+id/form_select_info_btn"
    android:layout_toStartOf="@+id/form_select_info_btn"
    android:background="@android:drawable/btn_dropdown"
    />

<ImageButton
    android:id="@+id/form_select_info_btn"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:scaleType="fitStart"
    android:src="@drawable/form_row_info"
    android:background="@android:color/transparent"
    android:layout_below="@+id/form_select_txt"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"/>

</RelativeLayout>

The view within the spinner:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textViewSpinnerItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
style="@style/SpinnerTextViewItem"
/>

Complete View: Complete View

View with Keyboard: (cannot scroll to view last two elements) Keyboard visable

Kai Windle
  • 63
  • 1
  • 7

2 Answers2

1

Put the all Tags in a Realtive Layout and the Relative Layout in ScrollView. As ScrollView takes Only One Child.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:paddingBottom="5dp">

<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
    android:id="@+id/form_multi_txt"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/testing"
    android:padding="10dp"/>

<EditText
    android:id="@+id/form_multi_edit"
    android:layout_width="fill_parent"
    android:layout_height="100dp"
    android:layout_below="@+id/form_multi_txt"
    android:layout_marginLeft="5dp"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:background="@drawable/edit_text_background"
    android:layout_toLeftOf="@+id/form_multi_info_btn"
    android:layout_toStartOf="@+id/form_multi_info_btn"
    android:inputType="textMultiLine"/>

<ImageButton
    android:id="@+id/form_multi_info_btn"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:scaleType="fitStart"
    android:src="@drawable/form_row_info"
    android:background="@android:color/transparent"
    android:layout_below="@+id/form_multi_txt"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"/>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Avinash Verma
  • 2,572
  • 1
  • 18
  • 22
0

It's because your activity layout needs to be adjusted once soft keyboard opens and you got this not set. What you need to do is to edit your Manifest and add

android:windowSoftInputMode="adjustResize"

to right <activity> tag. Here's Handling Input Method Visibility chapter in the docs, you may want to read to see what behaviours can you set with windowSoftInputMode

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141