这里的问题是,即使我没有将 fitsSystemWindows="true"设置为 xml 中的任何标记,它仍然看起来好像有 fitsSystemWindows="true"。如果您看不出区别,那就是在状态栏部分。
现在的结果:
我想要什么:
其他详细信息:
我已经在 styles.xml (v21) 中将半透明状态设置为 true
<android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapsing_toolbar_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="false" app:contentScrim="?attr/colorPrimary" app:expandedTitleMarginEnd="64dp" app:expandedTitleMarginStart="48dp" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <ImageView android:id="@+id/img" android:layout_width="match_parent" android:layout_height="250dp" android:fitsSystemWindows="false" android:scaleType="fitXY" android:src="@drawable/com_facebook_profile_picture_blank_portrait" app:layout_collapseMode="parallax" /> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:fitsSystemWindows="false" android:theme="@style/AppTheme.Toolbar" app:layout_collapseMode="pin" app:popupTheme="@style/AppTheme.PopupOverlay" /> </android.support.design.widget.CollapsingToolbarLayout>
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="a very long text, don't mind this, this is working as intended" />
v21/styles.xml
<resources>
<style name="AppTheme" parent="AppTheme.Base">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
</style>
</resources>
样式.xml
<resources>
<style name="AppTheme" parent="AppTheme.Base">
</style>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.Dark" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorPrimary</item>
</style>
<style name="AppTheme.Toolbar">
<item name="android:textColorPrimary">@color/white</item>
<item name="colorControlNormal">@color/white</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
最佳答案
这真的很令人困惑,但在我将 fitsSystemWindows="true"
放入所有标签后,它起作用了。
关于android - 状态栏下方的 CollapsingToolbarLayout 图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34961797/