How can I remove the options onscreen button on android?

How can I remove the options onscreen button on android? it’s unuseful, and it’s not pretty.

Appears by default in the cocos2dx apps.

What do you mean by “options onscreen button”? cocos2dx apps are run as full screen by default, which means everything is drawn by your code.

probably he means navigation bar on some android devices.
You must use immersive mode (google that)

Yeahh, I mean navigation bar as Dawid Drozd says, it’s the bar that nexus devices and tablets have. In some apps, appear the options button, in others don’t. In cocos2dx games appears by default.

Dawid Drozd wrote:

You must use immersive mode (google that)

Dawid, what do you mean with immersive mode?

Try to add

android:targetSdkVersion="12"

to AndroidManifest.xml

It is pretty easy:

https://developer.android.com/training/system-ui/immersive.html

It isn’t by “default in cocos2d-x” you are confusing Android and Cocos2d-x.

Hi, I tried the solution posted by Tobias, but it haven’t worked.

About immersive mode, I think that it’s not what I want, what this do is disable/unshow the onscreen buttons that are in some android phones. What I want is to disable only a button that in android apps is only show when you have an options menu, and that in cocos you haven’t.

The button that I want to remove is like the following:

You can see four buttons, the last one is the options button, that in android 4.x only appears when it has a function, but in cocos2dx apps always appears.

I think that now is more clear. There is a way to solve it?

Dawid Drozd wrote:

probably he means navigation bar on some android devices.
You must use immersive mode (google that)

Does it work on devices with Android older than 4.4?

Tobias S wrote:

Dawid Drozd wrote:
> probably he means navigation bar on some android devices.
> You must use immersive mode (google that)
>
Does it work on devices with Android older than 4.4?

I don’t think so, It’s only for kitkat devices.

Hi all !

You should use the latest version cocos2dx 3.12 , That version has updated hide virtual button by default . or if you use old version ( ex : cocos2d-x 3.9 )
In AppActivity.java :smile:

package org.cocos2dx.cpp;

import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
import org.cocos2dx.lib.Cocos2dxRenderer;

import android.os.Build;
import android.os.Bundle;

public class AppActivity extends Cocos2dxActivity {

private static Cocos2dxGLSurfaceView glSurfaceView;

@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

public Cocos2dxGLSurfaceView onCreateView() {
glSurfaceView = new Cocos2dxGLSurfaceView(this);

/*
* Hide softkey
*/
this.uiHide();

glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8); // Real devices
//glSurfaceView.setEGLConfigChooser(8 , 8, 8, 8, 16, 0); // Emulator or Genymotion Emulator

return glSurfaceView;
}

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

private void uiHide() {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
{
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);
}
}

static
{
System.loadLibrary(“cocos2dcpp”);
}
}

1 Like