android:theme="@android:style/Theme.NoTitleBar.Fullscreen" works on Application level but not at the activity level. Any clue?

Vikas Singh picture Vikas Singh · Apr 10, 2012 · Viewed 89k times · Source

I need to make one of my activities called MyNoStatusBarActivity.java a full-screen activity.

I have added in the Manifest :

<activity
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    android:name=".MyNoStatusBarActivity"
    android:noHistory="true"
    android:label="@string/app_name"
    android:configChanges="touchscreen|keyboard|keyboardHidden|navigation|orientation">
    ...
</activity>

And in the onCreate of my activity :

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    getWindow().setFlags(
        WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
}

Doing all this just hides the TITLE bar and not the STATUS bar.

Also if I use the manifest theme on the application level instead of my activity, it works but for all activities of my app which is not what I want. I want the no status bar only for one particular activity.

Help will be really appreciated. Thnx!

P.S : I am ok is this behavior is no longer available in Honeycomb/ICS. I need this just for 2.2 and 2.3

EDIT

Tried all the suggestions mentioned in other solutions in SO but no success yet. Theme works when applied to the application level but not on the activity level.

I am using HTC WildFire-S, android ver 2.3.5

Answer

Neoh picture Neoh · Apr 26, 2013

In your manifest xml, at application level put this:

<application
    ...
    android:theme="@android:style/Theme.NoTitleBar" >
</application>

and in the activity that you want to make full screen put this:

<activity

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

Remove all the setWindowsFeature or setFlag methods in onCreate.