我在github和这里使用基于这个例子的新的Android设计库chrisbanes/cheesesquare
我运行了这个例子,我遇到了CheeseDetailActivity里面的工具栏问题.工具栏未按预期显示.看看下面的图片:
在第一张图像中,您可以看到工具栏未正确显示.

在第二个图像中,您可以看到工具栏显示正确但通知栏为白色.发生这种情况是因为我从actiivty_detail.xml中删除android:fitsSystemWindows="true"了android.support.design.widget.CoordinatorLayout

我认为这fitsSystemWindows应该是真的,问题与此有关,android.support.design.widget.AppBarLayout但我不知道如何解决这个问题.我尝试marginTop了相同的高度,notificationBar但它没有工作.
任何建议表示赞赏:)
这是以下内容的一部分activity_detail.xml:
<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/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/detail_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="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
Run Code Online (Sandbox Code Playgroud) android android-layout android-toolbar android-design-library
我在底部提供了设计.
我希望在标签布局上面发生的事情:
所以我确实实现了1和3,但我无法实现2 - 当你慢慢滚动RecyclerView时,图像停留在它上面并且不会隐藏.
以下是我所做的事情:
检查底部的XML.
那么会发生什么:
这是一个有问题的视频:YOUTUBE
我试图调试CoordinatorLayout,当它调用按钮的hide()方法但我找不到问题.有任何想法吗?
编辑1:
如果删除cheesesquare示例中的工具栏,则会出现相同的错误.
我的测试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"
android:clickable="true"
android:background="@color/bg_secondary"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:elevation="1dp"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<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"
app:contentScrim="?attr/colorPrimary"
android:fitsSystemWindows="true">
<ImageView
android:id="@+id/img"
android:src="@drawable/header_bg"
android:scaleType="centerCrop"
android:cropToPadding="true"
app:layout_collapseMode="parallax"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/profile_tabs"
android:elevation="2dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="1dp"
app:pressedTranslationZ="12dp"
android:clickable="true"
app:rippleColor="@android:color/transparent"
android:src="@drawable/ic_launcher"
app:layout_collapseMode="parallax"
app:layout_anchor="@id/app_bar_layout"
app:layout_anchorGravity="bottom|left|end" …Run Code Online (Sandbox Code Playgroud) android ×2