gpt4 book ai didi

android - 需要完全透明的状态栏

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:42:48 26 4
gpt4 key购买 nike

嗨, friend 们,我想知道我可以更改状态栏颜色还是使其完全透明。

我已经尝试了很多东西,但我无法获得完全透明的状态栏,所以这是我的代码..

v21/style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

<item name="android:windowTranslucentStatus">true</item>

<item name="android:windowNoTitle">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>

style.xml

    <resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

</style>
</resources>

之后我的屏幕显示为... current login screen

我想要这样..

desired login screen

谁能帮忙?谢谢。

最佳答案

我知道回答这个问题已经晚了,但这对我有帮助,也可能对 future 的访客有帮助。

// transparent statusbar for marshmallow and above
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (yourView != null) {
yourView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
}

//make full transparent statusBar
if (Build.VERSION.SDK_INT >= 19 && Build.VERSION.SDK_INT < 21) {
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, true);
}
if (Build.VERSION.SDK_INT >= 19) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
if (Build.VERSION.SDK_INT >= 21) {
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
getWindow().setStatusBarColor(Color.TRANSPARENT);
}

public static void setWindowFlag(Activity activity, final int bits, boolean on) {
Window win = activity.getWindow();
WindowManager.LayoutParams winParams = win.getAttributes();
if (on) {
winParams.flags |= bits;
} else {
winParams.flags &= ~bits;
}
win.setAttributes(winParams);
}

关于android - 需要完全透明的状态栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37019028/

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