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?
To hide the Title Bar using the Android Manifest. xml file you need to set the Android theme to NoTitleBar like this: android:theme="@android:style/Theme.
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 .
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
.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With