Immersive mode is supported only on Android 4.4 and above, and the Appactivity code is modified as follows:
@Override PublicCocos2dxglsurfaceview Oncreateview () {Cocos2dxglsurfaceview Glsurfaceview=Super. Oncreateview (); Hidesystemui (); returnGlsurfaceview; } @Override Public voidOnwindowfocuschanged (BooleanHasfocus) { Super. onwindowfocuschanged (Hasfocus); if(Hasfocus && Build.VERSION.SDK_INT >= 19) {hidesystemui (); } } Private voidHidesystemui () {//Set the IMMERSIVE flag. //Set the content to appear under the system bars so the content//doesn ' t resize when the system bars hide and show. if(Build.VERSION.SDK_INT >= 21) {Cocos2dxglsurfaceview Decorview=cocos2dxglsurfaceview.getinstance (); Decorview.setsystemuivisibility (view.system_ui_flag_layout_stable|view.system_ui_flag_layout_hide_navigation|View.system_ui_flag_layout_fullscreen| View.system_ui_flag_hide_navigation//Hide nav Bar| View.system_ui_flag_fullscreen//Hide Status bar|view.system_ui_flag_immersive_sticky); } }
The effect is as follows:
cocos3.x implementing Android Immersive mode (full screen, hidden navigation bar i.e. virtual key)