android – PreferenceFragment在CollapsingToolbarLayout中没有滚动

我有PreferenceFragment和CollapsingToolbarLayout的问题.我有一个基本布局:
<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:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.base.BaseActivity">

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

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/ctlLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:minHeight="?attr/actionBarSize"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"></android.support.v7.widget.Toolbar>

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

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

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

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fabFav"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginRight="85dp"
    android:src="@android:drawable/ic_menu_save"
    app:layout_anchor="@id/appbarLayout"
    app:layout_anchorGravity="bottom|right|end"
    android:visibility="gone" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fabShare"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/fab_margin"
    android:src="@android:drawable/ic_menu_share"
    app:borderWidth="0dp"
    app:layout_anchor="@id/appbarLayout"
    app:layout_anchorGravity="bottom|right|end"
    android:visibility="gone" />

<fragment
    android:id="@+id/search_fragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:name="com.eventum.raedictionary.fragments.SearchFragment"
    tools:layout="@layout/fragment_search"/>

问题是当我用PreferenceFragment给Framelayout充气时,滚动不起作用,但正常的Fragment正常工作.

BaseSettingFragment settingsFragment = new BaseSettingFragment();

        fragmentTransaction = getFragmentManager().beginTransaction();

        fragmentTransaction.setCustomAnimations(R.transition.fade_in,R.transition.fade_out);

        fragmentTransaction.replace(R.id.fragment_container,settingsFragment);

        fragmentTransaction.commit();

我没有找到任何解决这个问题的方法,任何人都可以帮助我吗?

先感谢您.

PD:抱歉我的英文.

解决方法

PreferenceFragment基于ListView,它不支持CollapsingToolbarLayout所需的嵌套滚动API.您可以改为使用基于RecyclerView的 Preference Support LibraryPreferenceFragmentCompat,并且支持所需的嵌套滚动API.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...