Search code examples
androidstatusbar

Android: hide top status bar


Can I hide the Android top status bar (time & charging icon appears)? Actually there is some difference in the positing of elements when i run things on device and on emulator. I want to run my code and many different emulators for testing purpose, any help?


Solution

  • Dynamically in Java

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

    OR

    Declare in menifest.xml like..

    Add the following in application if you want to remove it for all the activities in an app:
    
    <application android:theme="@android:style/Theme.Black.NoTitleBar">
    
    Or for a particular activity:
    
    <activity android:theme="@android:style/Theme.Black.NoTitleBar">
    

    EDIT:-

    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    

    And write following in oncreate() method.

    @Override
    public void onCreate(android.os.Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
    
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    
        setContentView(R.layout.main);
    }