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?
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
.
You can modify your AndroidManifest.xml
:
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
or use android:theme="@android:style/Theme.Black.NoTitleBar"
if you don't need a fullscreen Activity.
Note: If you've used a 'default' view before, you probably should also change the parent class from AppCompatActivity
to Activity
.
android:theme="@android:style/Theme.Black.NoTitleBar"
is probably more useful unless you're making a game