potato
potato

Reputation: 4589

hide back, home and recents apps button in libgdx

Libgdx shows these buttons by default. Is it possible to hide them and show them only when user slides with finger down(I think this is how unity has done it)?

enter image description here

Upvotes: 1

Views: 536

Answers (2)

Kright
Kright

Reputation: 91

Instead of overriding android methods you can enable option in AndroidApplicationConfiguration

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();

    config.useImmersiveMode = true;  // libgdx will handle it

    initialize(new Main(), config);
}

Upvotes: 2

m.antkowicz
m.antkowicz

Reputation: 13581

To hide virtual Android buttons (on the phones that do not have physical buttons :) ) you have to set the application to use the Immersive Full-Screen mode.

You can achieve this by setting proper flags from android.view.View method by adding this code in your AndroidLauncher class

    @TargetApi(19)
    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        if (hasFocus) {
            getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
                View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
                View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }
    }

Take a look at this tutorial to get more information.

Upvotes: 1

Related Questions