【Android错误集锦】AppBarLayout is overlapping the RecyclerView in one of my xml files.

  • 时间:
  • 浏览:0
  • 来源:大发5分快3APP下载_大发5分快3APP官方

附参考博客:

什么的问题什么的问题:recyclerview 中的顶部数据被appbar遮盖,如下图红框所示

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

<android.support.design.widget.FloatingActionButton

android:id="@+id/fab"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="bottom|end"

android:layout_margin="@dimen/fab_margin"

app:srcCompat="@android:drawable/ic_dialog_email" />

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

<android.support.v7.widget.Toolbar

android:id="@+id/toolbar"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

android:background="?attr/colorPrimary"

app:popupTheme="@style/AppTheme.PopupOverlay" />

https://stackoverflow.com/questions/3810001099/appbarlayout-overlaps-recyclerview

<android.support.v7.widget.RecyclerView

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_below="@id/toolbar"

android:id="@+id/recycler_view"

android:layout_centerVertical="true"

android:layout_centerHorizontal="true"

app:layout_behavior="@string/appbar_scrolling_view_behavior" />

在activity_main.xml上边CoordinatorLayout布局下 即与AppBarLayout布局并列下打上去 如下代码

If you don't want the coordinated toolbar scrolling, replace CoordinatorLayout with a vertical LinearLayout.

<android.support.design.widget.AppBarLayout

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:theme="@style/AppTheme.AppBarOverlay">

When you are using CoordinatorLayout and AppBarLayout, you are setting up for that coordinated scrolling where the toolbar pushes out of the way first. But in order to get that, you need to give the view below the toolbar the appbar scrolling view behavior. This not only sets up the coordinated scroll, but tells the CoordinatorLayout to layout the lower view so that it appears beneath the toolbar.

正确处理辦法 :