问题
I tried with the following code to hide status bar but it doesn't work..
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
and to dim the bar i used
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
and it works.. Does any one know how to hide status bar on Android 4.0.4 device??
回答1:
Use the following in your Manifest
<activity
android:name=".abc"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
This however will only work on phones, Tablets do not support hiding of status bar.
回答2:
Try with this on your onCreate
method.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
回答3:
- add a style and extend Theme.AppCompat.NoActionBar , and add two item.
like this
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style
- setup your application with this theme.
like this
<application
...
android:theme="@style/AppTheme"
...>
</application>
回答4:
In your AndroidManifest just add it to android:theme
. Either of the following lines should work for you:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
You need to specify Fullscreen otherwise your status bar will be kept and only your Title bar will disappear.
回答5:
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
doesn't hide the status bar. It hides the navigation bar.
If you want to hide the status bar you should use:
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
or
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Read more here: https://developer.android.com/training/system-ui/status.html
回答6:
This Solution worked with me :
1- Root your device. use the tool in this site >> www.unlockroot.com
2- call this function at application start up >> https://stackoverflow.com/a/14940667/1995361
来源:https://stackoverflow.com/questions/13800009/hide-android-status-bar-for-my-application-on-android-4-0-4