【发布时间】:2015-11-16 15:12:57
【问题描述】:
我有这个布局:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways|snap"/>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</android.support.v7.widget.RecyclerView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:src="@drawable/ic_favorite_outline_white_24dp"/>
</android.support.design.widget.CoordinatorLayout>
设置@string/appbar_scrolling_view_behavior 属性将RecyclerView 移动工具栏的高度。
但是如果我需要 RecyclerView 的第一个元素与状态栏对齐怎么办。
我希望工具栏覆盖(位于上方)第一个元素。
换句话说,我不想要@string/appbar_scrolling_view_behavior 行为所需要的任何偏移量。
你能告诉我怎么做吗?
【问题讨论】:
标签: android android-support-library android-toolbar android-coordinatorlayout