How to remove Title Bar from Activity extending ActionBarActivity or AppcompatActivity with Dialog Theme

31,785

Solution 1

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>

Solution 2

Try

  getSupportActionBar().hide() 

if you are using AppCompatActivity

And

 getActionBar().hide() 

if your activity extends ActionBarActivity. Hope it helps.

Solution 3

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

ActionBar actionBar = getSupportActionBar();
actionBar.hide();

Solution 4

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

Solution 5

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 :)

Share:
31,785
Admin
Author by

Admin

Updated on July 26, 2022

Comments

  • Admin
    Admin almost 2 years

    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?