状态栏已隐藏,但仍可看到色调

时间:2017-12-05 13:54:25

标签: java android statusbar android-statusbar

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

设置状态栏颜色的代码

 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。即使setStatusBarColorTRANSPARENT。任何帮助将不胜感激。

As you can see, the status bar is hidden but the tint is seen

3 个答案:

答案 0 :(得分:0)

尝试在onCreate()

中添加此代码

Kotlin:

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)

答案 1 :(得分:0)

试试这个:

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

移动到其他视图或活动后,这些标记会重置。

答案 2 :(得分:0)

你可能已经尝试了这个,但以防万一:

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

相关问题