How do I make a LinearLayout scrollable?

After I start the activity I am unable to scroll down to see other buttons and options in the xml defined below.

Does anyone know how to make this scrollable?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_height="wrap_content"
 android:layout_width="fill_parent"
 android:background="#000044"
 android:isScrollContainer="true"
 android:orientation="vertical">
 <TextView
  android:id="@+id/title"
  android:text="@string/title"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textColor="#ffffff"/>
 <EditText
  android:id="@+id/editTitle"
  android:text=""
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"/>
 <TextView
  android:id="@+id/description"
  android:text="@string/description"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textColor="#ffffff"/>
 <EditText
  android:id="@+id/editDescription"
  android:text=""
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"/>
 <TextView
  android:id="@+id/location"
  android:text="@string/location"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textColor="#ffffff"/>
 <EditText
  android:id="@+id/editLocation"
  android:text=""
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"/>
 <TextView
  android:id="@+id/startTime"
  android:text="@string/startTime"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textColor="#ffffff"/>
 <DatePicker 
  android:id="@+id/DatePicker01" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content" />
 <TimePicker 
  android:id="@+id/TimePicker01" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content"/>
 <TextView
  android:id="@+id/endTime"
  android:text="@string/endTime"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textColor="#ffffff"/>
 <DatePicker 
  android:id="@+id/DatePicker02" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content" />
 <TimePicker 
  android:id="@+id/TimePicker02" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content"/>
 <Button
  android:id="@+id/buttonCreate"
  android:text="Create"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"/>
</LinearLayout>

My class code is

package com.example.blah;

import android.app.Activity;
import android.os.Bundle;

public class example extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

Place your layout in a ScrollView.


<?xml version="1.0" encoding="utf-8"?>
<ScrollView ...>

    <LinearLayout ...>

        ...
        ...

    </LinearLayout>

</ScrollView>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center|left"
        android:orientation="vertical">

        Your views go here...

    </LinearLayout>

</ScrollView>

Put your whole content in linear layout which is placed inside ScrollView.

ScrollView takes only one layout as its child.

isScrollContainer="true"

This property is used when your softkey in android pops up and still you want your view to scroll.


You can implement it using View.scrollTo(..) also.

postDelayed(new Runnable() {
            public void run() {

                counter = (int) (counter + 10);
                handler.postDelayed(this, 100);

                    llParent.scrollTo(counter , 0);
                }

            }
        }, 1000L);