Wednesday, 23 January 2013

Android Layout with Header Footer and scrollable Body content

<?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>
 

Note : Add android:windowSoftInputMode="adjustPan" to your activity in Android manifest.

If it does not work then add the following in the oncreate method of the activity

getWindow().setSoftInputMode(
                WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

output:

 

 

 

No comments:

Post a Comment

Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...