我的ListView不可滚动。我使用了坐标布局

时间:2016-02-17 12:06:21

标签: android listview android-fragments android-coordinatorlayout

我有一个带有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>

的ListView

            <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>

1 个答案:

答案 0 :(得分:0)

好的,在做了一些跟踪和错误之后我发现了一个修复程序。不确定它是否是正确的方法。但仍然发布了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>