滚动视图不起作用

ScrollView doesn't work

我的布局有一些复杂的布局,而且它们都很大。这就是为什么我需要 ScrollView。但是无论我尝试什么都不行。

这是我的布局文件:

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="match_parent"
         android:layout_width="fill_parent"
        android:fillViewport="true"
        android:layout_weight="1"
        android:orientation="vertical"
        >
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">
<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="1">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.33"
        android:id="@+id/Linear1"
        >

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="@color/tileColor1"
            android:layout_weight="1"
            android:id="@+id/tileLayout1"
            android:onClick="openFirst"
            >

我只发布了其中的一部分,但所有结束标签都可以,在我的 RelativeLayout 中有 2 个 textViews 和一张图片。结构相同的还有9个RelativeLayout

我该如何解决这个问题,为什么它不起作用?它甚至不显示滚动条。

编辑

我已经上传了my full layout to pastebin

编辑 2

在 developer.android 上说: You should never use a ScrollView with a ListView, because ListView takes care of its own vertical scrolling. Most importantly, doing this defeats all of the important optimizations in ListView for dealing with large lists, since it effectively forces the ListView to display its entire list of items to fill up the infinite container supplied by ScrollView.

我的根本不处理滚动。我想是这样的,因为我在代码中编辑了 LayoutParams。我该如何解决这个问题?

ScrollView 只接受一个子视图。因此,将其中的所有内容包装在一个 LinearLayout 中,并将 wrap_content 设置为高度,然后你就设置好了。

1. 尝试删除 android:layout_weight="1"android:orientation="vertical".

2.确保ScrollView里面只有一个ViewGroup(也就是他们说的一个child)。我假设你已经这样做了,但由于你没有提供完整的布局,我无法确认。

我有同样的问题,我不知道我的解决方案是否有帮助(主要是因为它是一个很晚的响应),但是我的 ScrollView 没有工作,因为设置了一个完全适合的布局屏幕,因此没有必要创建滚动。当增加我的布局时(我把我所有的物品都放在 android:layout_height = WRAP_CONTENT) 开始运行。