android - AppBarLayout 使用 fitsSystemWindows 错误地将状态栏高度添加到它自己的高度

标签 android android-coordinatorlayout android-collapsingtoolbarlayout android-appbarlayout fresco

设置

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/poi_detail_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.varese.PoiActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/poi_detail_app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/poi_detail_collapsing"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:toolbarId="@+id/poi_detail_toolbar">

            <com.facebook.drawee.view.SimpleDraweeView
                android:id="@+id/poi_detail_header_image"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fitsSystemWindows="true"
                app:layout_collapseMode="parallax"
                app:viewAspectRatio="1.43" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/poi_detail_toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                android:fitsSystemWindows="false"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

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

    <include layout="@layout/content_poi" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/fab_margin"
        app:fabSize="normal"
        app:layout_anchor="@id/poi_detail_app_bar"
        app:layout_anchorGravity="bottom|end"
        app:srcCompat="@drawable/ic_audio_play" />

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

现状

Here is how it turn out

有限制:

enter image description here

这是内容的实际高度:

 AppBar      height: 827
    Collapsing  height: 827
    HeaderImage height: 755
    Toolbar     height: 168

问题

AppBar 将状态栏高度添加到它的高度,导致 AppBar 比需要的稍长,显示 HeaderImage< 下方的红色条。所以基本上我期望高度为 755(在此手机上),但我得到了 755(HeaderImage 的高度)+ 72(Statusbar 的高度)。 HeaderImage 是一个 SimpleDraweeView(来自 Fresco),aspectRatio 为 1.43,因此它动态设置自己的高度(基于宽度),我无法硬编码 AppBar 的高度。

我不认为这是预期的行为,但也许我只是在 fitsSystemWindows 配方中遗漏了一些东西。

最佳答案

我也遇到过这个问题。请在此处的 bugtracker 上用星标标记此错误,以便谷歌修复此错误: https://issuetracker.google.com/issues/75707002

关于android - AppBarLayout 使用 fitsSystemWindows 错误地将状态栏高度添加到它自己的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49362134/

相关文章:

android - 如何避免频繁的位置更新?

android - 折叠工具栏布局 |滚动和布局问题 2

android - 如何像Facebook Profile一样在AppBar上隐藏ImageView?

android - 如何将 RecyclerView 放在 Toolbar 下方以及 TabLayout 和 ViewPager 上方还以自定义方式处理对滚动的响应?

java - 二进制 XML 文件行 #18 : Error inflating class android. support.design.widget.CollapsingToolbarLayout

android - 为什么向上滚动时滚动会停在折叠的工具栏处? (不扩大显示图像)

android - 从 ActionBar 中检索 fragment 内的操作布局

android - 用于向 android google map 添加标记的异步任务被卡住

java - 试图了解我是否需要 WakeLock

android - 使用 CoordinatorLayout 和 AppBarLayout 查看动画变得疯狂(有时)