Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Emulator doesn't Scroll down

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

like image 608
Harsha M V Avatar asked Apr 28 '11 08:04

Harsha M V


People also ask

How to scroll down in Android emulator?

Left-click and hold, and drag the screen to scroll.

Does Android emulator come with Android studio?

Get started with the emulator. The Android Emulator enables you to test your app on many different devices, virtually. The emulator comes with Android Studio by default, so you shouldn't have to manually install it.

Can Android emulator use microphone?

If you want to use the host audio data, you can enable that option by going to Extended Controls > Microphone and enabling Virtual microphone uses host audio input. This option is automatically disabled whenever the emulator is restarted.


1 Answers

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".

like image 170
rekaszeru Avatar answered Nov 12 '22 09:11

rekaszeru