'ListView is pushed up when keyboard goes up

I got this problem:

When I focus my EditText the keyboard comes up (ofcourse), but it also pushes my ListView up instead of going over it.
This is without selecting EditText:

---item 1---  
---item 2---  
---item 3---  
---item 4---  
---EditText---

With EditText selected:

---item 3---  
---item 4---  
---EditText---  
---Keyboard---  

now item 1 and 2, are out of the screen (at the top).

But what I try to achieve is:

---item 1---  
---item 2---  
---EditText---  
---Keyboard---  

This only happens when I got this in my manifest: android:windowSoftInputMode="adjustPan"
I use this because when I don't use that line, this happens:

---item 1---  
---item 2---   
---item 3---  
---keyboard---  

Now the EditText is behind the keyboard...

I hope you guys got some suggestions for how to get:

---item 1---  
---item 2---  
---EditText---  
---Keyboard---  

XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:orientation="vertical" >

<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="424dp" />

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:layout_weight="0.66" >



    <EditText
        android:id="@+id/txt_zoeken"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:ems="10" >

        <requestFocus />
    </EditText>



    <Button
        android:id="@+id/btn_zoeken"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:onClick="btn_zoeken"
        android:text="Button" />

</RelativeLayout>



Solution 1:[1]

Try this (wrapping your EditText in ScrollView), it worked for me when I was with the same kind of situation.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:orientation="vertical" >

<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="424dp" />

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_weight="0.66" >

        <EditText
            android:id="@+id/txt_zoeken"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:ems="10" >

            <requestFocus />
        </EditText>

        <Button
            android:id="@+id/btn_zoeken"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:onClick="btn_zoeken"
            android:text="Button" />
    </RelativeLayout>
</ScrollView>

Solution 2:[2]

add below code in listview tag.

android:focusableInTouchMode="false"
android:isScrollContainer="false"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 wasaig
Solution 2 Abhishek Dutt