Android的隐藏导航栏/留在沉浸式模式与软键盘外观 [英] Android Hide Navigation Bar/Stay in Immersive Mode with Soft Keyboard Appearance

查看:2311
本文介绍了Android的隐藏导航栏/留在沉浸式模式与软键盘外观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

工作正在使用沉浸式模式下使用以下code隐藏在每一个活动的导航栏和状态栏客户的应用程序:

Working on a client's app that is using immersive mode to hide the navigation bar and status bar on every activity using the following code:

int currentApiVersion = android.os.Build.VERSION.SDK_INT;

final int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

// This work only for android 4.4+
if (currentApiVersion >= 19) {

        getWindow().getDecorView().setSystemUiVisibility(flags);
        // Code below is for case when you press Volume up or Volume down.
        // Without this after pressing valume buttons navigation bar will
        // show up and don't hide
        final View decorView = getWindow().getDecorView();
        decorView
                .setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {

                    @Override
                    public void onSystemUiVisibilityChange(int visibility) {
                        if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                            decorView.setSystemUiVisibility(flags);
                        }
                }
         });
}

唯一的问题是,他们希望应用程序留在身临其境的模式,并没有显示出即使在软键盘显示输入到一个EditText导航栏。任何人都可以想办法总是有导航按钮(后退/隐藏键盘,家庭等)始终即使在​​使用键盘被隐藏?

The only problem is that they would like the app to stay in immersive mode and not show the navigation bar even when the soft keyboard is showing to type into an EditText. Can anyone think of a way to always have the navigation buttons (back/hide keyboard, home, etc) always be hidden even while using the keyboard?

推荐答案

请参见这个。我搜索了超过3小时的这个问题,该解决方案行之有效。我希望这将是有益的。

See this. I've searched for over 3 hours for this problem and that solution worked well. I hope it'll be helpful.

这篇关于Android的隐藏导航栏/留在沉浸式模式与软键盘外观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆