Reputation: 914
When my app starts it shows a title bar with the app icon before the actual layouting of my main activity is being displayed.
How do I get rid of that title bar?
I have a custom title bar (e.g. ActionBar
) that I use for my application but this is only setup during the onCreate
method of my activity.
If I add style NoTitleBar
to the Manifest I am getting NullPointerException when accessing using getActionBar
in the main activity in order to set my custom action bar.
Having
requestWindowFeature(Window.FEATURE_NO_TITLE);
in the onCreate
method does not help as it comes too late.
Upvotes: 0
Views: 149
Reputation: 239
In you manifest set the activity theme to Theme.noTitleBar
android:theme="@android:style/Theme.NoTitleBar"
In your activity onCreate method do the following:
// Apply default theme to your activity.
setTheme(R.style.YourAppTheme);
super.onCreate(savedInstanceState);
// Make sure action bar can be used.
supportRequestWindowFeature(Window.FEATURE_ACTION_BAR);
// Optionally, hide action bar from the screen (For example, login screen might have action bar hidden);
// getSupportActionBar().hide();
// Apply your layout here.
setContentView(R.layout.activity_main);
Upvotes: 1