You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * 模态框相关方法 */publicabstractclassDialogFns {
/** * 沉浸式显示模态框 * @param dialog 模态框 * @param context 当前调用端Activity */publicstaticvoidshowImmersive(Dialogdialog, Activitycontext){
//Here's the magic..//Set the dialog to not focusable (makes navigation ignore us adding the window)dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
//Set the dialog to immersivedialog.getWindow().getDecorView().setSystemUiVisibility(
context.getWindow().getDecorView().getSystemUiVisibility());
//Show the dialog! (Hopefully no soft navigation...)dialog.show();
//Clear the not focusable flag from the windowdialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
}
}
妖孽的bug
目前把安卓的App的界面以全屏模式现实,不现实上方状态栏和下方的导航栏已经没有问题。一次无意的操作发现,突然上方的状态栏出现了。后经过反正验证,发现和模态框有关,一开始并没多在意,以为是个别样式设置问题。后面发现只要是模态框就会破坏全屏沉浸式模式。
问题解决定位
这个问题比较棘手,官网似乎并没有提到。属于小小冷门,百度出的解决方案也是语焉不详,想这种解决针对性问题还是StackOverflow最靠谱
How do I maintain the Immersive Mode in Dialogs?
相关代码
调用部分
DialogFragment的内部实现也是Dialog,原理上是一样的,代码处理不同。
总结部分
代码重点就是
经过测试可行
The text was updated successfully, but these errors were encountered: