繁体   English   中英

ScrollView不起作用

[英]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

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

编辑

我已将完整版面上传到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. 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。 我该如何解决?

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

2.确保ScrollView只有一个ViewGroup (即,他们所说的一个孩子)。 我认为您已经完成了此操作,但是由于您没有提供完整的布局,因此无法确认。

ScrollView仅接受一个子视图。 因此,将其中的所有内容包装在LinearLayout中,并将wrap_content设置为height即可。

我遇到了同样的问题,我不知道我的解决方案是否有帮助(主要是因为响应太晚了),但是我的ScrollView不能正常工作,因为它设置了恰好适合屏幕的布局,因此没有必要创建滚动。 增加布局后(我将所有项目都放置在android:layout_height = WRAP_CONTENT )就可以使用了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM