简体   繁体   中英

How to disable StatusBar in android?

I have written a custom Action Bar. the problem is, in order to use this action bar, i am using my custom theme in manifest. I also want to disable StatusBar. how do i do that?

<resources>

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.

-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->

<item name="colorPrimary">@color/red</item>
<item name="colorPrimaryDark">@color/red</item>
</style>

First of all, google discourages that behavior saying:

You should never show the action bar without the status bar.

However if you insist to do so. Try this snippet:

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

Taken from: https://developer.android.com/training/system-ui/status.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM