schoenk
schoenk

Reputation: 914

How to get rid of title bar during app start

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

Answers (1)

Aleksey
Aleksey

Reputation: 239

  1. In you manifest set the activity theme to Theme.noTitleBar

    android:theme="@android:style/Theme.NoTitleBar"
    
  2. 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

Related Questions