Search code examples
javaandroidandroid-fullscreen

android full screen an activity and hide key bar


i am new in android programming! i want a full screen image like Hill Climb Racing (as you can see below)

Hill Climb Racing

i try to use

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

but it just disappear action bar and i want to disappear both action bar and android default key bar (home button, back and the another one)


Solution

  • If you are targeting android 4.0 and higher

    View decorView = getWindow().getDecorView();
    // Hide both the navigation bar and the status bar.
    // SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
    // a general rule, you should design your app to hide the status bar whenever you
    // hide the navigation bar.
    int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                  | View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
    

    Check this developer site for more detail information