S.Drumble3
S.Drumble3

Reputation: 59

Hide status bar in windowmanager

Please,somebody,tell me how to hide/disable status/notification bar using onluWindowManager, do not using WindowManager.LayoutParams.FLAG_FULLSCREEN, AndroidManifest or something that is not WindowManager.

Upvotes: 0

Views: 1864

Answers (6)

user13776577
user13776577

Reputation:

FLAG_LAYOUT_NO_LIMITS

As well as calculating the screen height, including the status bar


var resourceId = resources.getIdentifier("status_bar_height", "dimen", "android")
val statusBarHeight = if (resourceId > 0) {
    resources.getDimensionPixelSize(resourceId);
} else {
    0
}
val params = object : WindowManager.LayoutParams() {
    init {
        width = MATCH_PARENT
        height = resources.displayMetrics.heightPixels + statusBarHeight
        type = TYPE_APPLICATION_OVERLAY
        format = PixelFormat.TRANSLUCENT
        flags =
            FLAG_NOT_FOCUSABLE or FLAG_NOT_TOUCH_MODAL or FLAG_LAYOUT_IN_SCREEN or FLAG_LAYOUT_NO_LIMITS
    }
}

enter image description here

Upvotes: 0

Ivan Ivanov
Ivan Ivanov

Reputation: 912

Put this line in your activity onCreate() method above setContentView() :

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

Hope it help!

Upvotes: 1

thuongle
thuongle

Reputation: 537

You can put these code in your onCreate() method of your activity:

@Override
protected void onCreate(Bundle savedInstanceState) {
   if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else { 
        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
        decorView.setSystemUiVisibility(uiOptions);
        ActionBar actionBar = getSupportActionBar();
        actionBar.hide();
    }
}

Hope it help!

Upvotes: 0

german
german

Reputation: 57

this worked for me, but i had to call the method every time i wanted to make sure the flag was like this

        anyViewInTheLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

Upvotes: 2

ZelvaJan
ZelvaJan

Reputation: 353

You can do it programmatically like this:

View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

More info on official pages: http://developer.android.com/training/system-ui/status.html

Upvotes: 0

rosu alin
rosu alin

Reputation: 5830

use this as a style:

<style name="Theme.Transparent" parent="android:Theme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:backgroundDimEnabled">false</item>
</style>

Upvotes: 0

Related Questions