can not remove title bar in Activity

arsenal picture arsenal · Aug 4, 2014 · Viewed 12.7k times · Source

i want to remove title on top of my Activity. i tried this two way they work but not in api level 8.

1:

<style name="NOtitleTheme" parent="Theme.AppCompat.Light">
<item name="android:windowFullscreen">true</item>
   <item name="android:windowNoTitle">true</item> </style>

2:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

any idea why this does not work on api 8?

once i managed to remove it in api 8, but i do not remember how.


EDIT:

Solved! the problem was this.requestWindowFeature(Window.FEATURE_NO_TITLE) does not work on API 8, and also <item name="android:windowNoTitle">true</item> does not work, but actionBar.hide() works , the reason that getSupportActionBar() returns null was using one of the two option before, i just forget to remove both. when i remove one i add other(what a a stupid !) thanks all! (sorry for bad English)

Answer

prabhakaran picture prabhakaran · Aug 4, 2014

Add to your Manifest:

for full screen:

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

or (hide title alone)

       <activity
        android:name="youtpackagename.activityname"
        android:theme="@android:style/Theme.NoTitleBar" >

or else use below code before setContentView method .

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

or

{
  ActionBar actionBar = getActionBar(); or getSupportActionBar();
  actionBar.hide();
}

Edit:

final ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);

Its working fine below api 8 also.. i hope this will help you