如何避免Android Scrollview进入无限滚动?

如何避免Android Scrollview进入无限滚动?,android,android-scrollview,Android,Android Scrollview,这是我的滚动视图布局。它只是无限滚动。我需要的只是用户在活动中看到的元素的滚动。我已经尽了最大的努力,但是没有成功。这是布局图 <?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_cont

这是我的滚动视图布局。它只是无限滚动。我需要的只是用户在活动中看到的元素的滚动。我已经尽了最大的努力,但是没有成功。这是布局图

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


设置LinearLayout(id parentLayout)的高度以包裹内容


ScrollView设置为包装内容,但其子级设置为填充父级。这毫无意义,因为有些东西需要提供一个尺寸。

为什么要使用这个?android:layout_marginLeft=“-20dp”android:layout_marginStart=“-20dp”编辑了我的问题。对不起。应该是线性布局中出现的按钮。好。现在运行你的应用程序,告诉我我试过了。同样的结果。滚动视图滚动条是无限的。我想保证金不是一个问题。请阅读@nmw答案,这是您的指南。因为这种布局格式不需要滚动视图。你为什么要用这个?