Hide Notification bar

后端 未结 9 1550
[愿得一人]
[愿得一人] 2020-11-27 03:17

Anyone know how to disable/hide notification bar at the top which show battery and other things in android. Any help will be appreciated.

EDIT: Plea

相关标签:
9条回答
  • 2020-11-27 04:09

    you can do like this in onCreate() method :

    View decorView = getWindow().getDecorView();
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
    ActionBar actionBar = getActionBar();
    actionBar.hide();
    
    0 讨论(0)
  • 2020-11-27 04:12

    Successfully implemented a slightly modified version of @Martin's suggestion along with a custom theme to get rid of BOTH the Status and Navigation Bar.

    public class MyActivity extends Activity {
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        //* Hides Notification Bar
        getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    
        setContentView(R.layout.activity_my);
    }
    

    Top part is used to get rid of the Status bar. Add the following code to your @styles as a resource to kill off the NavBar as well.

     <resources> <style name="NoNav" parent="@android:style/Theme.Holo.Light">
        <item name="android:windowActionBar">false</item>
        <item name="android:windowNoTitle">true</item>
    </style> </resources>
    

    After you add this to your resource file, pop open AndroidManifest.xml and chance your application theme to "@style/NoNav".

    Android UI bloatware eliminated :)

    0 讨论(0)
  • 2020-11-27 04:16
    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
            if (hasFocus) {
                getWindow().getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
            }
        }
    
    0 讨论(0)
提交回复
热议问题