Android – How to hide the title bar for an Activity in XML with existing custom theme

androidandroid-layouttitlebar

I want to hide the titlebar for some of my activities. The problem is that I applied a style to all my activities, therefore I can't simply set the theme to @android:style/Theme.NoTitleBar.

Using the NoTitleBar theme as a parent for my style would remove the title bar from all of my activities.

Can I set a no title style item somewhere?

Best Answer

Do this in your onCreate() method.

//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);

//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

//set content view AFTER ABOVE sequence (to avoid crash)
this.setContentView(R.layout.your_layout_name_here); 

this refers to the Activity.

Related Topic