2

I know this question has been asked for a million times. But none of the answers helped me.
Every time I want to remove the TITLE BAR on MainActivity which extends ActionBarActivity, my application crashes or nothing happens. I have tried everything I could - changed AndroidManifest settings, added:

requestWindowFeature(Window.FEATURE_NO_TITLE);

and

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

in any possible way into the onCreate method. But nothing seems to work properly. I really hope somebody has an answer because it is getting really frustrating.

kl1432
  • 23
  • 3

3 Answers3

2

Don't extend ActionBarActivity which is causing the error, instead use Activity. Unless your min api level is not below 11, it won't change that much (here you can read why, but AppCompatActivity will probably cause the same error).
If it extends Activity, you can use getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN) (min api lvl 15).

Community
  • 1
  • 1
Andi
  • 36
  • 5
0

I donot have the reputation to comment. So I am posting it as an answer.

Where are you calling the method

requestWindowFeature(Window.FEATURE_NO_TITLE);

According to my knowledge it must be called before

setContentView(R.Layout.yourlayoutname);

of your onCreate method.

Can you post the logcat if you are getting the same issue even when you call the methods before the setContentView() method.

You can also use theme from the manifest to remove the title bar from the activity.

Reply for any further assistance. Hope this helps. Cheers :)

0

For removing title bar you can use FullScreenTheme by adding the code below to styles:

<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light">
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

You can use above theme for a particular activity or for all activity:

To set this theme for a single activity go to manifest and use:

<activity
    ........
    android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">

To set this theme for all activities go to manifest and use:

<application
        ......
        android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"/>
Pankaj
  • 7,908
  • 6
  • 42
  • 65