【发布时间】:2016-08-29 13:31:17
【问题描述】:
我在滚动活动中的 Recyclerview 中遇到了空白问题。 请帮我解决这个问题。我已经检查了我所知道的所有内容,例如没有边距、填充,通过删除 FAB 进行了尝试。但问题依然存在。
我的 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"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/id_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end" />
</android.support.design.widget.CoordinatorLayout>
【问题讨论】:
-
发布你完整的xml代码,我可以看到一些部分丢失
-
对我来说,您从 AppBarLayout 的高度看起来比内容大,并且出现空白。用包装内容替换它
-
对,确保你的布局有合适的高度。对我来说,它看起来像错过了状态栏的大小。检查如果从 CoordinatorLayout 中删除“fitsSystemWindows”会发生什么。将其保留在 AppBar 中。
-
您提到的代码似乎没问题。需要检查 RecyclerView 的列表项布局。
-
这个问题发生在appbar和recycler之间,好像和wxh没有关系
标签: android android-recyclerview android-appbarlayout