【问题标题】:Status bar is hidden but the tint is still seen状态栏已隐藏,但仍可以看到色调
【发布时间】:2017-12-05 13:54:24
【问题描述】:

我有一个 Android 应用,它有一个播放视频的 Activity。虽然我的应用程序中的某些活动通常具有动态状态栏颜色,但当视频活动处于横向时,我隐藏了状态栏。但即使我全屏隐藏状态栏,状态栏的色调仍然存在。请告诉我如何隐藏状态栏色调。

设置状态栏颜色的代码

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                SystemBarTintManager tintManager = new SystemBarTintManager(((Activity) context));
                tintManager.setStatusBarTintEnabled(true);
                tintManager.setNavigationBarTintEnabled(false);
                tintManager.setTintColor(Color.parseColor("#" + dynamicColor));
                float f = Float.parseFloat(".7");
                tintManager.setTintAlpha(f);
            }

我用来移除状态栏颜色的代码

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                SystemBarTintManager tintManager = new SystemBarTintManager(this);
                tintManager.setStatusBarTintEnabled(false);
                tintManager.setNavigationBarTintEnabled(false);
                float f = Float.parseFloat("0");
                tintManager.setTintAlpha(f);
                getWindow().setStatusBarColor(Color.TRANSPARENT);
            }

现在在去除色调的代码中,我已将标志 setStatusBarEnabled 设置为 false。甚至setStatusBarColor 也是TRANSPARENT。任何帮助将不胜感激。

【问题讨论】:

    标签: java android statusbar android-statusbar


    【解决方案1】:

    尝试在onCreate()中加入这段代码

    科特林:

    window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
    

    Java:(不确定)

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

    【讨论】:

      【解决方案2】:

      试试这个:

      View decorView = getWindow().getDecorView();
      int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
      decorView.setSystemUiVisibility(uiOptions);
      ActionBar actionBar = getActionBar();
      actionBar.hide();
      

      一旦您移动到不同的视图或活动,这些标志就会重置。

      【讨论】:

      • 我已经编写了这段代码,它确实被调用了,但即使这样它也不起作用。我设法获得全屏并隐藏状态栏,但色调覆盖不会消失。
      • setSystemUiVisibility() 函数只有在调用它的视图可见时才有效。你确保这一点吗?
      • 当我的活动进入横向时,我从 onConfigurationChanged() 调用它。
      【解决方案3】:

      您可能已经尝试过,但以防万一:

      View decorView = getWindow().getDecorView();
      // Hide the status bar.
      int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
      decorView.setSystemUiVisibility(uiOptions);
      // Remember that you should never show the action bar if the
      // status bar is hidden, so hide that too if necessary.
      ActionBar actionBar = getActionBar();
      actionBar.hide();
      

      来自 https://developer.android.com/training/system-ui/status.html

      【讨论】:

        猜你喜欢
        • 2014-04-23
        • 1970-01-01
        • 2021-09-25
        • 1970-01-01
        • 1970-01-01
        • 2015-05-07
        • 1970-01-01
        • 2014-10-14
        • 2011-04-29
        相关资源
        最近更新 更多