cocos3.x implementing Android Immersive mode (full screen, hidden navigation bar i.e. virtual key)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.