CoordinatorLayout 中的 RecyclerView 仅在向下滚动后显示项目

RecyclerView in CoordinatorLayout shows items only after scrolling down

我在 CoordinatorLayout 中使用 RecyclerView 来显示搜索结果项。但是,这些项目仅在滚动了一下后才显示,我不明白为什么。我认为这与 RecyclerView 没有调整到 CoordinatorLayout 中缩小的尺寸有关。 对此有什么线索吗?

布局非常简单,基本模板由 android studio 提供,RecyclerView 除外。

activity_results_recycler.xml:

<?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="com.alamgir_swi.abjad.ResultsRecyclerActivity">

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

        <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/toolbar_layout"
            android:fitsSystemWindows="true" android:layout_width="match_parent"
            android:layout_height="match_parent" app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:contentScrim="?attr/colorPrimary">

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

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

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

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

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

content_results_recycler.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_results_recycler"
    tools:context="com.alamgir_swi.abjad.ResultsRecyclerActivity"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/abjadList"
    >
</android.support.v7.widget.RecyclerView>

abjad_entry.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:padding="10dp" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Text"
        android:id="@+id/abjad_entry"
        android:layout_gravity="right" />
</RelativeLayout>

感谢您的任何提示。

找到问题的根源。

从 CursorLoader 获取数据后,我需要在我的 RecyclerView.LayoutManager 实例上调用 notifyDataSetChanged()。