设置
<?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>
现状
有限制:
这是内容的实际高度:
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/