打开对话框时如何隐藏导航栏? [英] How do you keep the Navigation Bar hidden when opening dialogs?

查看:126
本文介绍了打开对话框时如何隐藏导航栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有Theme.AppCompat.Dialog父级的主题.关键是我的所有活动都使导航栏保持隐藏状态,但是当打开对话框时,它会返回带有黑色有时透明的背景色.有没有办法在打开对话框期间将其隐藏?

I have a theme that has a Theme.AppCompat.Dialog parent. The thing is all my activities keeps the navigation bar hidden, but when a dialog is opened, it returns with a sometimes black and sometimes transparent background color. Is there a way to keep it hidden during opening dialogs?

推荐答案

我终于通过重写自定义对话框的show()方法解决了这个问题.

I finally solved this by overriding the show() method of the custom dialog that I have.

@Override
public void show() {
    // Set the dialog to not focusable.
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);

    // Show the dialog with NavBar hidden.
    super.show();

    // Set the dialog to focusable again.
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
}

这篇关于打开对话框时如何隐藏导航栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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