Nevermore
Nevermore

Reputation: 882

How to avoid this Android Scrollview from going into infinite scroll?

This is my layout of the scrollView. It just scrolls infinitely. I need the scroll just for the elements that the user sees in the activity. I have tried all my efforts to it however, it didnt work out. Heres the layout..

<?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="wrap_content"
android:orientation="vertical" >

<LinearLayout
    android:id="@+id/parentLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:layout_marginLeft="-20dp"
    android:layout_marginStart="-20dp" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
        </Button>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
        </Button>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
        </Button>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
        </Button>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
        </Button>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="15dp"
        android:layout_marginLeft="100dp"
        android:layout_marginStart="100dp"
        android:gravity="center"
        android:text="Create event" >
    </Button>
</LinearLayout>

Upvotes: 2

Views: 1651

Answers (1)

nmw
nmw

Reputation: 6764

Set the height of the LinearLayout (id parentLayout) to wrap_content.

The ScrollView is set to wrap_content, but its child is set to fill_parent. This makes no sense, as something needs to provide a size.

Upvotes: 3

Related Questions