简体   繁体   English

Android:键盘打开时导航栏隐藏

[英]Android: Navigation bar is hiding when keyboard opens

I have a dialog that starts within a Service that contains several EditTexts. 我有一个对话框,该对话框在包含多个EditText的服务中启动。 My issue is that when an EditText gets focus, the keyboard appears and the navigation bar disappears. 我的问题是,当EditText获得焦点时,键盘出现,导航栏消失。 Is there a way to prevent the navigation bar from disappearing? 有没有办法防止导航栏消失?

This is the dialog code (from inside the service): 这是对话框代码(来自服务内部):

@Override
public int onStartCommand(Intent intent, int flags, int startId)
{
    final LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
    _view = inflater.inflate(R.layout.dialog_notif, null);

    _edit_1 = (EditText) _view.findViewById(R.id.edit1);
    _edit_2 = (EditText) _view.findViewById(R.id.edit2);

    _dial = new Dialog(this);
    _dial.requestWindowFeature(Window.FEATURE_NO_TITLE);
    _dial.getWindow().setBackgroundDrawable(new ColorDrawable(0x66000000));
    _dial.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
    _dial.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    _dial.setContentView(_view);
    _dial.setCanceledOnTouchOutside(false);
    _dial.setOnDismissListener(new DialogInterface.OnDismissListener()
    {
        @Override
        public void onDismiss(DialogInterface dialogInterface)
        {
            stopSelf();
        }
    });
    _dial.show();

    return START_STICKY;
}

This is what it looks like: 看起来是这样的:

之前和之后:键盘隐藏的导航栏

you are creating Dialog using context of Service : 您正在使用Service上下文创建Dialog

_dial = new Dialog(this);

which is strongly UNrecomended. 强烈建议不要这样做。 your navigation bar is hiding probably because of theming/styling of Dialog . 您的导航栏处于隐藏状态,可能是因为Dialog的主题/样式。 Consider starting new Activity , which will have custom dialog-like-style 考虑启动新的Activity ,它将具有类似对话框的自定义样式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM