Android Emulator doesn't Scroll down

10,482

You should wrap your layout / the part you want to scoll into a ScrollView.

e.g. you can rewrite your layout as:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
    <LinearLayout android:orientation="vertical"
        android:layout_height="wrap_content" android:layout_width="wrap_content">
        <TextView [...]
        [...] 
    </LinearLayout>
</ScrollView>

so your root tag will be a ScrollView, and you just paste your current layout inside.
you just need to remove the namespace declaration from your LinearLayout, and declare it in the ScrollView.

The ScrollView API Docs might be helpful, and of course, Romain Guy's "ScrollView's Handy tricks".

Share:
10,482
Harsha M V
Author by

Harsha M V

I turn ideas into companies. Specifically, I like to solve big problems that can positively impact millions of people through software. I am currently focusing all of my time on my company, Skreem, where we are disrupting the ways marketers can leverage micro-influencers to tell the Brand’s stories to their audience. People do not buy goods and services. They buy relations, stories, and magic. Introducing technology with the power of human voice to maximize your brand communication. Follow me on Twitter: @harshamv You can contact me at -- harsha [at] skreem [dot] io

Updated on June 03, 2022

Comments

  • Harsha M V
    Harsha M V almost 2 years

    I am creating a layout as follows and when I emulate it in the AVD. It doesn't Scroll down to see the conten below the fold.

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_height="wrap_content"
        android:layout_width="wrap_content">
    
        <TextView android:text="@string/UserFormWelcome"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:textSize="20px" android:gravity="center" />
    
        <TextView android:text="@string/name" android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:textStyle="bold"
            android:paddingTop="20px" android:paddingLeft="10px" />
    
    
        <TableLayout android:layout_height="wrap_content"
            android:layout_width="wrap_content">
    
            <TableRow android:layout_height="wrap_content"
                android:layout_width="match_parent" android:paddingTop="20px">
    
                <TextView android:text="@string/firstname"
                    android:layout_width="fill_parent" android:layout_height="wrap_content"
                    android:width="100px" android:paddingLeft="10px" />
    
                <EditText android:id="@+id/LastName" android:width="200px"
                    android:layout_width="fill_parent" android:layout_height="wrap_content" />
    
            </TableRow>
    
            <TableRow android:layout_height="wrap_content"
                android:layout_width="match_parent">
    
                <TextView android:text="@string/lastname"
                    android:layout_width="fill_parent" android:layout_height="wrap_content"
                    android:paddingLeft="10px" />
    
                <EditText android:id="@+id/LastName" android:width="200px"
                    android:layout_width="fill_parent" android:layout_height="wrap_content" />
    
            </TableRow>
    
        </TableLayout>
    
    
        <TextView android:text="@string/dob" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:textStyle="bold"
            android:paddingTop="20px" android:paddingLeft="10px" />
    
        <TableLayout android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:stretchColumns="3"
            android:paddingTop="20px" android:paddingLeft="10px">
            <TableRow>
                <TextView android:text="@string/date" android:layout_width="wrap_content"
                    android:layout_height="wrap_content" android:layout_column="0" />
    
                <TextView android:text="@string/month" android:layout_width="wrap_content"
                    android:layout_height="wrap_content" android:layout_column="1" />
    
                <TextView android:text="@string/year" android:layout_width="wrap_content"
                    android:layout_height="wrap_content" android:layout_column="2" />
            </TableRow>
            <TableRow>
                <Spinner android:id="@+id/spinnerDate" android:layout_width="wrap_content"
                    android:layout_height="wrap_content" android:layout_column="0" />
    
                <Spinner android:id="@+id/spinnerMonth" android:layout_width="wrap_content"
                    android:layout_height="wrap_content" android:layout_column="1" />
    
                <Spinner android:id="@+id/spinnerYear" android:layout_width="wrap_content"
                    android:layout_height="wrap_content" android:layout_column="2" />
            </TableRow>
    
    
        </TableLayout>
    
        <LinearLayout android:id="@+id/linearLayout1"
            android:orientation="vertical" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:paddingLeft="10px">
    
            <TextView android:text="@string/sex" android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:textStyle="bold"
                android:paddingTop="20px" />
    
            <RadioGroup android:id="@+id/radioGroup1"
                android:orientation="horizontal" android:layout_width="wrap_content"
                android:layout_height="wrap_content">
                <RadioButton android:text="Male" android:id="@+id/rdbMale"
                    android:layout_height="wrap_content" android:layout_width="wrap_content"
                    android:paddingRight="20px" android:checked="true" />
                <RadioButton android:text="Female" android:id="@+id/rdbFemale"
                    android:layout_height="wrap_content" android:layout_width="wrap_content" />
            </RadioGroup>
    
        </LinearLayout>
    
    
        <LinearLayout android:orientation="vertical"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:paddingLeft="10px">
    
            <TextView android:text="@string/city" android:id="@+id/textView3"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:textStyle="bold" android:paddingTop="20px"
                android:paddingBottom="10px" />
    
            <Spinner android:id="@+id/citySpiner" android:layout_width="wrap_content"
                android:layout_height="wrap_content">
            </Spinner>
        </LinearLayout>
    
    </LinearLayout>
    

    enter image description here

  • Harsha M V
    Harsha M V about 13 years
    ok. this is new to me :( can u share an example or a tutorial
  • Codemonkey
    Codemonkey about 13 years
    Google will have a lot of examples for you, really. Just google "scrollview android" - you simply put a ScrollView container as the very root of your XML. Android takes care of the rest.