Reputation: 417
In my code I write:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.setContentView(R.layout.activity_main);
I've written all of it before the setContentView()
call is made but it doesn't work.
I've already used the theme in android studio to remove the title bar and set the app to fullscreen but nothing changed.
How can I remove or hide the title bar that shows by default, when developing an android app?
Upvotes: 4
Views: 7935
Reputation: 61
Add the following code in onCreate() method before setContentView(...)
requestWindowFeature(Window.FEATURE_NO_TITLE);
getSupportActionBar().hide();
The getSupportActionBar() method is used to retrieve the instance of ActionBar class. Calling the hide() method of ActionBar class hides the title bar.
Upvotes: 5
Reputation: 8237
1. Create a new style definition in your styles.xml
file and make it a child of Theme.AppCompat.Light.NoActionBar
.
For example:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
2. Add the new style definition to your application tag in the AndroidManifest.xml
file
<application
...
android:theme="@style/AppTheme">
Add the following properties to a new or existing style definition in the styles.xml
file and ensure the style definition has been referenced in the AndroidManifest.xml
file, as above:
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
Upvotes: 6
Reputation: 141
go to values and select styles.xml change AppTheme to
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
Upvotes: 3