【发布时间】:2015-07-24 21:45:59
【问题描述】:
我正在使用最新版本的设计支持库,但遇到了问题。在包含 CollpasingToolbarLayout 和 RecyclerView 的协调器布局中,RecyclerView 有时会向上设置状态栏的高度。我确定这与此视图使用“fitsSystemWindows”xml 属性隐藏状态栏这一事实有关。
这里是发生了什么的屏幕:
如您所见,RecyclerView 底部有一个不应该存在的边距。
这是 XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bit="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:background="@color/activity_background_color"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<include layout="@layout/toolbar_image"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/fa_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
bit:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
“toolbar_image”是这个视图:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
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:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_backdrop_height"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="@color/actionbar_body_color"
app:expandedTitleMarginStart="@dimen/toolbar_title_left_margin"
app:collapsedTitleTextAppearance="@style/Widget.Bandsintown.ToolbarTitleTextAppearance"
app:expandedTitleMarginBottom="@dimen/toolbar_title_bottom_margin">
<ImageView
android:id="@+id/toolbar_backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:transitionName="@string/transition_image"
app:layout_collapseMode="parallax"
tools:ignore="UnusedAttribute" />
<View
android:id="@+id/toolbar_bottom_gradient"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:layout_gravity="bottom"
android:background="@drawable/dark_gradient_ascending"/>
<View
android:id="@+id/toolbar_top_gradient"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:layout_gravity="top"
android:fitsSystemWindows="true"
android:background="@drawable/dark_gradient_descending"/>
<TextView
android:id="@+id/toolbar_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/toolbar_title_left_margin"
android:layout_marginBottom="12dp"
android:textColor="@android:color/white"
android:layout_gravity="bottom"
style="@style/Widget.Bandsintown.ToolbarSubtitleTextAppearance"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
我还录制了正在发生的事情的视频。在这个剪辑中,它需要几次尝试才能实现,因此您可以先查看它应该做什么,然后再查看错误。
这里是链接:https://dl.dropboxusercontent.com/u/97787025/device-2015-07-24-143017.mp4
在我在其他地方使用的与 NestedScrollView 一起使用的 CoordinatorLayout 中不会发生同样的问题。对此的任何帮助将不胜感激,我感觉它是一个库错误,但如果有修复,请告诉我。谢谢!
【问题讨论】:
标签: android