美文网首页
cocos2dx 横屏游戏 输入法 navigationbar不

cocos2dx 横屏游戏 输入法 navigationbar不

作者: 小屈屈 | 来源:发表于2017-02-24 14:16 被阅读0次

    使用textfiled用作输入,   安卓上输入完关闭输入法后navigationbar不隐藏, 挡住游戏画面

    原理是当获取cocos2dx封装的editor, 然后加入焦点变更的回调

    AppActivity中

    private Cocos2dxGLSurfaceView glSurfaceView;

    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);

    }

    private class EditorOnFocusChangeListener implements OnFocusChangeListener{

    @Override

    public void onFocusChange(View v, boolean hasFocus)

    {

    if (hasFocus == false)

    {

    hideSystemUI();

    }

    }

    }

    然后在onCreate里面

    glSurfaceView.getCocos2dxEditText().setOnFocusChangeListener(new EditorOnFocusChangeListener());

    相关文章

      网友评论

          本文标题:cocos2dx 横屏游戏 输入法 navigationbar不

          本文链接:https://www.haomeiwen.com/subject/axrwwttx.html