gpt4 book ai didi

安卓 Lollipop : ImageView ignoring fitsSystemWindows attribute (transparent status bar)

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:15:16 28 4
gpt4 key购买 nike

我目前正在开发一个应用程序,我想为其启用透明状态栏。我想要一个 ImageView(我需要它的 scaleType 属性)覆盖整个屏幕,以便图像显示在状态栏下方。这是我的布局:

<android.support.v4.widget.DrawerLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@drawable/picture" />

<android.support.v7.widget.Toolbar
(...toolbar stuff...)
/>

(...some other stuff...)

</RelativeLayout>

<include layout="@layout/drawer" />
</android.support.v4.widget.DrawerLayout>

如您所见,它是一个常规的 DrawerLayout。请注意,DrawerLayoutRelativeLayoutImageView 都将 fitsSystemWindows 属性设置为 true。

我的问题是:如果我在上面的代码中将背景资源(如颜色或图片)设置为 DrawerLayoutRelativeLayout,我可以看到状态栏“下方”的颜色或图片,完全符合我的要求,但是 ImageView 的“src”可绘制对象始终显示在其下方,就好像它忽略了 fitsSystemWindows 属性完全。

我的主题有以下属性:

<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@color/primary_dark</item>

由于 primary_dark 是半透明的黑色(无论如何这应该无关紧要,因为正如我所说,这似乎是我的 ImageView 独有的问题。透明状态栏非常适合 DrawerLayoutRelativeLayout

最佳答案

这很适合我

您在每个 viewGroup 参数中都有 android:fitsSystemWindows="true"。尝试在 ImageView 中只留下一个。

或者完全删除所有这些。

关于安卓 Lollipop : ImageView ignoring fitsSystemWindows attribute (transparent status bar),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28177313/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com