协调器布局与ViewPager和ListFragment不滚动

时间:2016-01-02 10:41:42

标签: android android-listfragment android-coordinatorlayout

我在view pager中实施了Coordinator layout,其中包含ListFragment。视图寻呼机工作正常,但列表不滚动,

任何人都可以帮忙吗?我是否必须实现某些功能才能识别触摸方向,然后禁用触摸事件?

协调员布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:fitsSystemWindows="true"
tools:context=".MainActivity">

    <android.support.design.widget.AppBarLayout android:id="@+id/app_bar"
        android:layout_height="wrap_content" android:layout_width="match_parent"
        android:theme="@style/AppTheme.AppBarOverlay">

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

            <android.support.v7.widget.Toolbar android:id="@+id/toolbar"
                android:layout_height="?attr/actionBarSize" android:layout_width="match_parent"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

            <com.passwordstore.utility.SlidingTabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/colorPrimary" />

            <View
                android:layout_width="match_parent"
                android:layout_height="4dp"
                android:background="@android:color/white"
                android:foreground="@drawable/shadow"/>

            <android.support.v4.view.ViewPager
                android:id="@+id/pager"
                android:layout_height="0dp"
                android:layout_width="match_parent"
                android:layout_weight="1"
                android:background="@android:color/white"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

        </LinearLayout>

    </android.support.design.widget.AppBarLayout>

    <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" android:id="@+id/frameLayout">

        <include layout="@layout/activity_password_list" />

    </FrameLayout>

    <android.support.design.widget.FloatingActionButton android:id="@+id/fabNew"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:layout_margin="@dimen/fab_margin" android:src="@drawable/ic_add_white_24dp"
        app:layout_anchor="@+id/frameLayout"
        app:layout_anchorGravity="bottom|right|end"/>

</android.support.design.widget.CoordinatorLayout>

片段 - activity_password_list:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/item_list"
android:name="com.passwordstore.fragment.PasswordListFragment" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_marginLeft="16dp"
android:layout_marginRight="16dp" tools:context=".PasswordListActivity"
tools:layout="@android:layout/list_content" />

1 个答案:

答案 0 :(得分:0)

我在同一个问题上得到的结果相同,我只需要使用这些custom layouts,您可能需要查看一下:

https://github.com/TheLittleNaruto/SupportDesignExample/tree/master/app/src/main/java/com/thelittlenaruto/supportdesignexample/customview