statusbar – Android: hide top status bar-ThrowExceptions

Exception or error:

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?

How to solve:

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);
}

###

To completely remove system bar from Android Emulator(tested with Android 4.0.3):

  • Navigate to %USER_HOME%\.android\avd\avd_name.avd\
  • Edit config.ini :

    hw.mainKeys=no – turn system bar OFF
    hw.mainKeys=yes – turn system bar ON

###

try something like this :

         <activity android:name=".MainActivity"
            android:label="@string/app_name"  android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
           </activity>

Or do something like this before your setContentView() in onCreate

requestWindowFeature(Window.FEATURE_NO_TITLE)

Leave a Reply

Your email address will not be published. Required fields are marked *