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

  • 时间:
  • 浏览:1
  • 来源:大发彩神在线计划—大发彩神计划怎么来的

<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" />

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

补救最好的办法:

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.

附参考博客:

<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" />

<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.AppBarLayout

android:layout_width="match_parent"

android:layout_height="wrap_content"

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

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

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

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

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

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