Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在显示碎片对话框时使应用程序全屏显示_Java_Android - Fatal编程技术网

Java 如何在显示碎片对话框时使应用程序全屏显示

Java 如何在显示碎片对话框时使应用程序全屏显示,java,android,Java,Android,我使我的应用程序全屏,但当我创建并显示一个片段对话框时,它将退出全屏 我尝试了两种方法,但都不适用于我,请查看代码1和代码2 代码1: 添加 添加true 到my style.xml 代码2: 在片段对话框中重写onShow @Override public void show(FragmentManager manager, String tag) { getDialog().getWindow().setFlags(WindowManager.Layo

我使我的应用程序全屏,但当我创建并显示一个片段对话框时,它将退出全屏

我尝试了两种方法,但都不适用于我,请查看代码1和代码2

代码1: 添加
添加true
到my style.xml 代码2: 在片段对话框中重写onShow

    @Override
    public void show(FragmentManager manager, String tag)
    {
        getDialog().getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
        super.show(manager, tag);
        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
        getDialog().getWindow().getDecorView().setSystemUiVisibility(uiOptions);
        getDialog().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
    }
没有发生任何事情,我的应用程序再次从全屏退出

@Override
    public void show(FragmentManager manager, String tag)
    {
        getDialog().getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
        super.show(manager, tag);
        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
        getDialog().getWindow().getDecorView().setSystemUiVisibility(uiOptions);
        getDialog().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);

        // add these two line
        getDialog().requestWindowFeature(1);
        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(0));
    }
试试这个:

@Override
public void onResume() {
    // Get existing layout params for the window
    ViewGroup.LayoutParams params = getDialog().getWindow().getAttributes();
    // Assign window properties to fill the parent
    params.width = WindowManager.LayoutParams.MATCH_PARENT;
    params.height = WindowManager.LayoutParams.WRAP_CONTENT;
    getDialog().getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
    // Call super onResume after sizing
    super.onResume()

}

好的,我自己有答案 这段代码使问题得以解决:

getDialog().getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
getDialog().getWindow().getDecorView().setSystemUiVisibility(getActivity().getWindow().getDecorView().getSystemUiVisibility());

getDialog().setOnShowListener(new DialogInterface.OnShowListener() {
    @Override
    public void onShow(DialogInterface dialog) {
        //Clear the not focusable flag from the window
        getDialog().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);

        //Update the WindowManager with the new attributes (no nicer way I know of to do this)..
        WindowManager wm = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
        wm.updateViewLayout(getDialog().getWindow().getDecorView(), getDialog().getWindow().getAttributes());
    }
});

你的类扩展了DialogFragment?@igmerodriguez yeapi尝试一下,不工作:(.我的应用程序停止全屏复制粘贴你的代码,但问题仍然出现了:(我的操作栏隐藏在style.xml中,但每次我弹出一个片段对话框时,这个该死的主导航栏都会出现。)