Android layout with title, scrollview and footer, footer with keyboard
I need a snippet with a header and footer. The content that is in between (of course) should be scrollable. Everything is going well so far. But inside the scrollview there must be an edittext, so at some point the keyboard will appear. Unfortunately the keyboard also brings up the footer OR when I change the windowSoftInputMode to customize the Pan it hides the header.
In short, I want the footer to be at the bottom, but the content of the scroll is visible (when the keyboard focuses on the edittext). Also the title should be visible at all times.
Any suggestions on how to accomplish this behavior?
source to share
Android footer and scrollable content (Body)
You can try this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:padding="10dp" >
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="header"
android:textSize="40sp" >
</TextView>
</LinearLayout>
<LinearLayout
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:padding="10dp" >
<TextView
android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="footer"
android:textSize="40sp" >
</TextView>
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/footer"
android:layout_below="@id/header" >
<LinearLayout
android:id="@+id/body"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/edit1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp" />
<EditText
android:id="@+id/edit2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp" />
<EditText
android:id="@+id/edit3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp" />
<EditText
android:id="@+id/edit4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp" />
<EditText
android:id="@+id/edit5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp" />
<EditText
android:id="@+id/edit6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp" />
<EditText
android:id="@+id/edit7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp" />
<EditText
android:id="@+id/edit8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp" />
<Button
android:id="@+id/btn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Submit" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
Add android:windowSoftInputMode="adjustPan"
to your activity in your android manifest.
source to share