2016-09-17 54 views
0

我正在制作一款Android游戏,并且使用setSystemUiVisibility设置我的SystemUiVisibility不显示顶栏和其他系统UI,但是现在当你在游戏中死亡时,我想显示AlertDialog与你的分数。当我显示AlertDialog时,它将SystemUiVisibility带回,我不希望发生这种情况。有人知道如何解决这个问题。这里是我使用的是现在的AlertDialog代码:AlertDialog显示SystemUiVisibility

dlgAlert.setMessage("You lost, you hit the right color " + Points + " times"); 
       dlgAlert.setTitle("You died"); 
       dlgAlert.setPositiveButton("OK", null); 
       dlgAlert.create().show(); 

回答

0

让对话框不可聚焦,当我们创建它(这样我们就不会触发用户交互),然后进行它的显示它可聚焦后。

dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); 

//Show the dialog! 
dialog.show(); 

//Set the dialog to immersive 
dialog.getWindow().getDecorView().setSystemUiVisibility(
context.getWindow().getDecorView().getSystemUiVisibility()); 

//Clear the not focusable flag from the window 
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); 
+0

我没有getWindow –

+0

https://developer.android.com/reference/android/app/Dialog.html – SofDroid