当软键盘可见时隐藏状态栏

时间:2016-03-16 22:34:02

标签: android android-softkeyboard statusbar android-fullscreen

我想在状态栏中隐藏状态栏,这就是我的工作方式:

if (Build.VERSION.SDK_INT < 16) {
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        } else {
            View decorView = activity.getWindow().getDecorView();
            int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN
            decorView.setSystemUiVisibility(uiOptions);
        }

}

问题是当软键盘变得可见(输入EditText)时,状态栏会回来。

1 个答案:

答案 0 :(得分:-1)

如果你想对.java做,只需代码:

if (Build.VERSION.SDK_INT < 16) {
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }

但是如果你想在xml上隐藏状态栏,只需代码:

<application
    ...
    android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" >
    ...
</application>

请查看http://developer.android.com/intl/es/training/system-ui/status.html以获取更多信息......