【问题标题】:My ListView is not scrollable. I have used coordinate layout我的 ListView 不可滚动。我使用了坐标布局
【发布时间】:2016-02-17 12:06:21
【问题描述】:

我有一个导航抽屉,里面还有 2 个片段。一个片段有一个列表视图,但列表视图没有滚动。我正在获取数据,但唯一的问题是列表视图不允许向下滚动。

activity_main

            <android.support.design.widget.CoordinatorLayout
            android:id="@+id/rootLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

            <android.support.design.widget.TabLayout
            android:id="@+id/tabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabGravity="fill"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>

            <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/white" />
            </android.support.design.widget.AppBarLayout>

            </android.support.design.widget.CoordinatorLayout>
            <android.support.design.widget.NavigationView
            xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:id="@+id/Shitstuff"
            app:itemTextColor="@color/colorPrimary"
            app:menu="@menu/drawermenu"
            android:layout_marginTop="-24dp">
            </android.support.design.widget.NavigationView>
            </android.support.v4.widget.DrawerLayout>

列表视图

            <FrameLayout 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"
                tools:context=".FragmentA">

                <ListView
                    android:layout_width="match_parent"
                    android:layout_height="fill_parent"
                    android:id="@+id/listView"
                    android:divider="#020202"
                    android:dividerHeight="0.5dp" />

            </FrameLayout>

【问题讨论】:

  • 请找到图片链接:postimg.org/image/6gvifajnd
  • 我只得到前 7 条记录.. 但 url 有大约 118 个 jsonArrays..
  • 使用嵌套滚动和分页或只使用嵌套滚动,即使显示所有数据,您也可以向下滚动
  • 我在 ListView 中添加了 android:nestedScrollingEnabled="true" 但仍然无法向下滚动..
  • 但还有一件事嵌套滚动仅适用于棒棒糖或更高版本

标签: android listview android-fragments android-coordinatorlayout


【解决方案1】:

好的,在做了一些跟踪和错误之后,我找到了一个修复..不确定这是否是正确的做法..但仍然发布 activity_main 布局文件。 只需比较两个 activity_main 布局文件。我已经对其进行了一些更改。

                <?xml version="1.0" encoding="utf-8"?>
            <android.support.v4.widget.DrawerLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/drawerLayout">

            <android.support.design.widget.CoordinatorLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <FrameLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/containerView">

            <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="@android:color/white"
            android:layout_gravity="center_horizontal|top" />

            </FrameLayout>
            <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:background="#FFDD00"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

            <android.support.design.widget.TabLayout
            android:id="@+id/tabLayout"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:tabGravity="fill"
            android:background="#FFDD00"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
            </android.support.design.widget.AppBarLayout>
            </android.support.design.widget.CoordinatorLayout>

            <android.support.design.widget.NavigationView
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:id="@+id/Shitstuff"
            app:itemTextColor="@color/colorPrimary"
            app:menu="@menu/drawermenu"
            android:layout_marginTop="-24dp">

            </android.support.design.widget.NavigationView>
            </android.support.v4.widget.DrawerLayout>

【讨论】:

  • 列表滚动,但tablayout隐藏了部分布局
猜你喜欢
  • 1970-01-01
  • 2011-05-17
  • 1970-01-01
  • 1970-01-01
  • 2015-11-26
  • 1970-01-01
  • 1970-01-01
  • 2021-01-01
  • 2019-03-18
相关资源
最近更新 更多