java - 无法滚动下面有 GridView 和 ListView 的屏幕

标签 java android listview scrollview

我有以下 xml,它下面有 Gridview 和 framelayout。 我的要求是如果我向上滚动屏幕整个屏幕应该滚动,但对我来说只有 ListView 滚动

下面是xml文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:focusableInTouchMode="true"
android:paddingBottom="@dimen/activity_vertical_margin">

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/time_card_header"
    android:id="@+id/scrollView">
<GridView
     android:id="@+id/timecard_grid"
     android:layout_width="match_parent"
     android:layout_height="130dp"
     android:layout_margin="3dp"
     android:fitsSystemWindows="true"
     android:gravity="center_horizontal"
     android:horizontalSpacing="1dp"
     android:numColumns="3"
     android:stretchMode="columnWidth"
     android:verticalSpacing="1dp" />
    </ScrollView>
<FrameLayout
    android:id="@+id/timecard_reports"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:background="@color/white"
    android:layout_below="@+id/scrollView"/>
</RelativeLayout

最佳答案

其实GridView和Listview已经滚动了。无需将上述小部件放在 ScrollView 中。首先,删除 ScrollView 。我认为您需要将 FrameLayout 固定在底部并在上方显示 gridview。首先在线性布局中使用 FrameLayout 并设置 align_parentbottom 为真。之后请将 gridview 放在 FrameLayout 上方。这将解决问题。

关于java - 无法滚动下面有 GridView 和 ListView 的屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46412022/

相关文章:

java - 为什么 Java、C# 程序第二次运行速度更快

android - 通过本地网络在移动设备之间进行通信

java - ElasticSearch 和 Apache HttpAsyncClient

Java:访问枚举(enum)中的常量

java - 缩短 Java 代码的语言技巧?

android - 选择复选框后,所有 ListView 项目复选框均未选中

Android:在带有姓名和号码的 ListView 中设置联系人照片

Android Ionic Cordova - 错误 : Failed to get absolute path to installed module

android - 如何检测 Android 音频流下溢/溢出?

Android ListView,其中新项目推送旧项目 'down'