android - 如何去除状态栏的黑暗

android - how to remove darkness from status bar

我的状态栏变暗了,我想将其删除。我删除了状态和工具栏颜色以用渐变颜色替换它

这些是我的代码:

<style name="AppTheme.TransparentTheme">
    <item name="android:navigationBarColor">@android:color/transparent</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">false</item>
</style>

在我的代码中:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS );

结果是这样的:

您可以将此代码用于要去除深色以及要显示的颜色的特定屏幕。将此代码放在 class

中的 setContentView 之后
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        // clear FLAG_TRANSLUCENT_STATUS flag:
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(getResources().getColor(R.color.Your_color));

 to change the same color in the navigation bar

window.setNavigationBarColor(@ColorInt int color)
    }

试试这个然后告诉我。