cocos-creator 安卓适配全面屏手机

环境:Cocos-Creator V1.10
1,在AndroidManifest文件中添加下面一行代码


2,在AppActivity.java中添加函数

@Override
public Cocos2dxGLSurfaceView onCreateView() 
{
    ....
    //调用新增的函数
    this.hideSystemUI();
    // TestCpp should create stencil buffer
    glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);

    ....
}

// 新增函数
private void hideSystemUI()
{
    // Set the IMMERSIVE flag.
    // Set the content to appear under the system bars so that the content
    // doesn't resize when the system bars hide and show.
    glSurfaceView.setSystemUiVisibility(
        Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_LAYOUT_STABLE
        | Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
        | Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
        | Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
        | Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
        | Cocos2dxGLSurfaceView.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}

@Override
public void onWindowFocusChanged(boolean hasFocus)
{
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus)
    {
        this.hideSystemUI();
    }
}

你可能感兴趣的:(cocos-creator 安卓适配全面屏手机)