cocos2dx 横屏游戏 输入法 navigationbar不消失

使用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不消失)