Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 333
Mikhail Kharbanov Avatar asked Jun 10 '15 02:06

Mikhail Kharbanov


3 Answers

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>
like image 92
John O'Reilly Avatar answered Oct 15 '22 13:10

John O'Reilly


Try

  getSupportActionBar().hide() 

if you are using AppCompatActivity

And

 getActionBar().hide() 

if your activity extends ActionBarActivity. Hope it helps.

like image 30
Krishna Avatar answered Oct 15 '22 14:10

Krishna


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

ActionBar actionBar = getSupportActionBar();
actionBar.hide();
like image 16
saksham agarwal Avatar answered Oct 15 '22 14:10

saksham agarwal