Android:ScrollView 不滚动

2024-03-23

我正在尝试创建一个布局,其中包含标题、标题下方的横幅,然后横幅下有几个 ListView。我希望除标题之外的整个屏幕都可以滚动。现在我知道 ListView 不会在 ScrollView 中滚动,因此我将 ListView 的高度设置得足够大以显示所有项目。问题是,即使在这些更改之后,我仍然看到 ListView 正在独立滚动,并且整个屏幕不可滚动。

`

<include
    android:id="@+id/logo_header"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    layout="@layout/screen_header" />

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:layout_weight="0.8"
            android:background="#f2f2f2">

            <include
                android:id="@+id/mcUser"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                layout="@layout/complaint_reporters_details"
                android:layout_weight="2" />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="horizontal"
                android:weightSum="9"
                android:layout_weight="2">

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:orientation="vertical"
                    android:weightSum="1"
                    android:layout_weight="3"
                    android:focusableInTouchMode="false"
                    android:paddingLeft="30dp"
                    android:paddingRight="30dp">

                    <ImageView android:id="@+id/mcShowList"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:gravity="center"
                        android:layout_marginTop="5dp"
                        android:layout_marginBottom="5dp"
                        android:scaleType="fitXY"
                        android:src="@drawable/list_icon"
                        android:layout_weight="0.2" />

                    <TextView android:id="@+id/mcShowList_label"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:gravity="center"
                        android:textStyle="bold"
                        android:textSize="12sp"
                        android:textColor="#929292"
                        android:maxLines="1"
                        android:text="List"
                        android:layout_weight="0.8"
                        android:layout_marginTop="-8dp" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:orientation="vertical"
                    android:weightSum="1"
                    android:layout_weight="3"
                    android:gravity="center_vertical|center_horizontal"
                    android:paddingLeft="30dp"
                    android:paddingRight="30dp">

                    <ImageView android:id="@+id/mcShowMap"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:gravity="center"
                        android:layout_marginTop="5dp"
                        android:layout_marginBottom="5dp"
                        android:scaleType="fitXY"
                        android:src="@drawable/map_view"
                        android:layout_weight="0.2"/>

                    <TextView android:id="@+id/mcShowMap_label"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:gravity="center"
                        android:textStyle="bold"
                        android:textSize="12sp"
                        android:textColor="#929292"
                        android:maxLines="1"
                        android:text="Map"
                        android:layout_weight="0.8"
                        android:layout_marginTop="-8dp" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:orientation="vertical"
                    android:weightSum="1"
                    android:layout_weight="3"
                    android:focusableInTouchMode="false"
                    android:paddingRight="30dp"
                    android:paddingLeft="30dp">

                    <ImageView android:id="@+id/mcShowAnalytics"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:gravity="center"
                        android:layout_marginTop="5dp"
                        android:layout_marginBottom="5dp"
                        android:scaleType="fitXY"
                        android:src="@drawable/analytics_icon"
                        android:layout_weight="0.2" />

                    <TextView android:id="@+id/mcShowAnalytics_label"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:gravity="center"
                        android:textStyle="bold"
                        android:textSize="12sp"
                        android:textColor="#929292"
                        android:maxLines="1"
                        android:text="Analytics"
                        android:layout_weight="0.8"
                        android:layout_marginTop="-10dp" />

                </LinearLayout>

            </LinearLayout>

        </LinearLayout>

        <RelativeLayout
            android:layout_weight="0.2"
            android:layout_width="fill_parent"
            android:layout_height="400dp">

            <FrameLayout
                android:id="@+id/mcMapContainer"
                android:layout_width="match_parent"
                android:layout_height="fill_parent"/>

            <LinearLayout
                android:id="@+id/mcAnalyticsContainer"
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="fill_parent">

                <FrameLayout
                    android:id="@+id/mcChartContainer"
                    android:layout_gravity="center"
                    android:layout_width="200dp"
                    android:layout_height="200dp"/>

                <GridView
                    android:id="@+id/mcAmenityList"
                    android:layout_height="0dp"
                    android:layout_weight="7"
                    android:layout_width="match_parent"
                    android:numColumns="3"/>

            </LinearLayout>

            <LinearLayout
                android:id="@+id/mcListContainer"
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:weightSum="1">

                <TextView
                    android:text="Open Complaints"
                    android:textColor="@color/red_btn_bg_color"
                    android:textSize="18dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center_vertical|center_horizontal"
                    android:padding="5dp" />

                <ListView
                    android:id="@+id/mcListOpen"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"/>

                <TextView
                    android:text="Closed Complaints"
                    android:textColor="@color/red_btn_bg_color"
                    android:textSize="18dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center_vertical|center_horizontal"
                    android:padding="5dp" />

                <ListView
                    android:id="@+id/mcListClosed"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"/>

            </LinearLayout>

        </RelativeLayout>

    </LinearLayout>

</ScrollView>

`


将滚动视图的高度从match_parent更改为wrap_content。因为滚动视图只有在其总高度大于父视图的高度时才启用滚动。即替换

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

用这个代码:

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true">
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android:ScrollView 不滚动 的相关文章

随机推荐

  • 如何在Xcode编译中集成.proto文件?

    我正在尝试将 Android 应用程序移植到 ios 和 mac xcode 生态系统 我的应用程序使用 Google proto buffs 并使用说明https github com alexeyxo protobuf swift bl
  • 使用 Intellij 在远程服务器上部署/调试 Java 代码

    我想在远程服务器上运行我的java代码以获得更快的速度 该服务器非常强大 我想要的是将我的 Intellij 连接到该远程服务器并运行我的代码 但我仍然想在我的本地计算机 即我的笔记本电脑 上使用 IntelliJ 我在 IntelliJ
  • jQuery 的 space 和 > 选择器有什么区别?

    两者有什么区别space http docs jquery com Selectors descendant ancestordescendant and gt http docs jquery com Selectors child选择器
  • 如何通过文件将参数传递给tortoiseproc.exe?

    我正在使用 java 中的 Runtime getRuntime exec 以编程方式生成要提交到 cmd exe 的命令 该命令是tortoiseproc忽略形式的命令 tortoiseproc command ignore path f
  • 在 Python 3 中创建抽象属性会导致 AttributeError

    如何在 python 中创建抽象属性 import abc class MyClass abc ABC abc abstractmethod property def foo self pass 结果出现错误AttributeError a
  • 如何将 PostgreSQL 数据库迁移到 SQLServer 数据库?

    我有一个 PostgreSQL 数据库 我想将其迁移到 SQL Server 架构和数据 我很穷 所以我不想付任何钱 我也很懒 所以不想做太多工作 目前我正在逐个桌子做这个 大约有100个桌子要做 这是极其乏味的 有什么技巧可以达到我想要的
  • JavaScript 支持的网站的自动导航

    我需要在 Python 中自动导航 JavaScript 支持的网站 以便我可以抓取一些内容 我碰到鸡足 http groups csail mit edu uid chickenfoot quickstart html 这是一个 Fire
  • 使用 CakePHP 分页助手进行引导分页

    我正在尝试让 CakePHP 的分页助手与 bootstrap 很好地配合 也就是说 我希望我的分页元素看起来像 bootstrap 的 但由 CakePHP 生成 目前我的视图页面上有这个 它产生以下标记 div class pagina
  • 在 C 中使用 mmap 读取二进制文件时出现段错误

    我正在尝试在 C 中使用 mmap 只是为了看看它到底是如何工作的 目前我尝试使用 mmap 逐字节读取二进制文件 我的代码是这样的 include
  • Android - 在 invalidate() 上重绘后监听器

    在我要求视图失效后 我希望在视图完成重绘后收到通知 正如中所述这个答案 https stackoverflow com a 5073130 72746 the invalidate 方法不调用视图的onDraw UI 立即执行 但会在消息队
  • 索引 null 变量时未引发 php 未定义索引通知

    我很想知道 PHP 中的以下行为是否是有意的 而且 如果有意的话 通过创建索引来从空变量初始化数组被认为是可以接受的 如第一个代码片段中所做的那样 error reporting E ALL arr null echo arr blah n
  • 我可以制作两栏水晶报表吗?

    我有一份报告 其中包含该月每一天的一个详细信息行 我想在左侧的一个 组列 中显示第 1 到 15 天的信息 在右侧显示其他天的信息 每个 组列 都包含四个信息列 我可以通过拆分报告数据库查询列来手动完成此操作 但我真的希望有一种更优雅的方法
  • Objective C 距离字符串格式化程序

    我有一个距离作为浮动 我正在寻找一种方法来为人类读者很好地格式化它 理想情况下 我希望随着它变大 它从 m 变为 km 并很好地舍入数字 转换成里程将是一个额外的好处 我确信很多人都需要其中之一 我希望有一些代码在某个地方 这是我想要的格式
  • 在init块中初始化变量并在kotlin中为该变量定义一个setter

    我想写这段代码 但它不起作用 private var a Int set value field a Code init a 2 我必须在声明变量时对其进行初始化 为什么会发生这种情况 我该如何解决 您的属性有一个自定义设置器 当您调用时a
  • Magento:在一页结账中显示审核步骤

    我一生都无法弄清楚这一点 我想立即在 Magento 的一页结账上显示订单审核步骤 处理订单之前的最后一步 有什么建议么 谢谢大家 如果你查看 onepage phtml 的底部 你会看到 accordion openSection opc
  • 如何通过 Scala 中的 Play Framework 2.5 流式传输压缩文件(即时)?

    我想流式传输一些文件并即时压缩它们 以便用户可以将多个文件下载到一个压缩文件中 而无需向本地磁盘写入任何内容 但是 我当前的实现将所有内容保存在内存中 并且不适用于大文件 有什么办法可以解决吗 我正在研究这个实现 https gist gi
  • FCM 数据消息无法在 Firefox 中加载

    我正在使用 Web FCM 进行云消息传递 当我发送一个通知有了标题和正文 Firefox 和 Chrome 都会显示通知并且工作正常 但是当我尝试发送 FCM 时Data消息 Firefox 不接收和记录消息 我正在使用一个HTTPS安全
  • 如何鼓励 MediaWiki 上的非匿名编辑?

    Problem 在工作中我们有一个部门维基 运行媒体维基 http www mediawiki org 不幸的是有几个 人们在没有登录的情况下进行编辑 这使得追踪变得非常困难 向下编辑询问有关内容的问题 有两种策略可以改善这一点 鼓励登录编
  • Jquery .delay().fadeOut 取消/清除队列..可能吗?如何?

    我需要一些帮助 是否可以取消链接延迟 Mn Base TopBox show function timedur element fadeIn delay timedur fadeOut Mn Base TopBox cancelFadeou
  • Android:ScrollView 不滚动

    我正在尝试创建一个布局 其中包含标题 标题下方的横幅 然后横幅下有几个 ListView 我希望除标题之外的整个屏幕都可以滚动 现在我知道 ListView 不会在 ScrollView 中滚动 因此我将 ListView 的高度设置得足够