38

I had to extend my Activity with theme Theme.AppCompat.Light.Dialog from ActionBarActivity before and now from AppcompatActivity, because my Base Activity extends this one.

But now with new appcompat v7 (v22) library my Activity started to show title bar despite the fact that i use custom style with items windowActionBar=false, android:windowNoTitle=true. But until appcompat library upgraded there isn't such problem, title bar wasn't showed.

If my activity extends FragmentActivity everything is ok and i understand that maybe i use a bad pattern that my dialog activity extends from AppcompatActivity but i would like to know is there a way to remove title bar?

Mikhail Kharbanov
  • 441
  • 1
  • 5
  • 9

9 Answers9

73

I had same issue and needed to do something like following to resolve (note use of "windowNoTitle" instead of "android:windowNoTitle")

<style name="Theme.MyDialog" parent="@style/Theme.AppCompat.Light.Dialog">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>
John O'Reilly
  • 10,000
  • 4
  • 41
  • 63
20

Try

  getSupportActionBar().hide() 

if you are using AppCompatActivity

And

 getActionBar().hide() 

if your activity extends ActionBarActivity. Hope it helps.

16

You can hide the action bar at runtime by calling hide(). For example:

ActionBar actionBar = getSupportActionBar();
actionBar.hide();
Piyush
  • 18,895
  • 5
  • 32
  • 63
saksham agarwal
  • 250
  • 3
  • 14
  • Android Studio complained until I wrapped the actionBar.hide(); in a null check: if (actionBar != null) {actionBar.hide();} – proximous Sep 25 '15 at 18:27
12

Only one thing work in AppCompat Theme - supportRequestWindowFeature(Window.FEATURE_NO_TITLE);

Martin Tournoij
  • 26,737
  • 24
  • 105
  • 146
Andoctorey
  • 728
  • 9
  • 11
9

To solve the actionbar on class extend AppCompatActivity I start with define new theme extend from main theme in style.xml file :

style.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

and implement noactionbar theme to activity that you want in AndroidManifest.xml. Hope this help :)

Febriansyah
  • 101
  • 1
  • 4
8

If you're using support library use:

getSupportActionBar().setDisplayShowTitleEnabled(false);

If not then use

getActionBar().setDisplayShowTitleEnabled(false);
Obaidah
  • 101
  • 1
  • 4
  • None of the style based method worked for me (my Activity inherits from AppCompatActivity); but this one did: thanks! – DenisGL Dec 30 '16 at 19:10
1

Adding android:theme="@style/AppTheme.NoActionBar" in AndroidManifest.xml does the trick in my case.

@Brexx Galangue solution gave me the following runtime error:

java.lang.RuntimeException: Unable to start activity
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

MinnuKaAnae
  • 1,646
  • 3
  • 23
  • 35
Marc
  • 604
  • 1
  • 4
  • 11
-1

Try to add this code on your manifest, specifically, to the activity that you want to disappear its Actionbar:

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

hope it helps :D

Piyush
  • 18,895
  • 5
  • 32
  • 63
-1
 public class MainActivity extends AppCompatActivity {

  @Override protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_main);
     getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
     getSupportActionBar().setCustomView(R.layout.custom_title_bar);

  }  
}
MinnuKaAnae
  • 1,646
  • 3
  • 23
  • 35
pruthwiraj.kadam
  • 1,033
  • 10
  • 11