10

My android app has tab navigation using an action bar. It works well, but it bothers me that during the first boot of the app, a small default action bar briefly shows up before being replaced by the real, tab-navigation action bar. My onCreate starts like this:

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    setContentView(R.layout.activity_main);

    //Set up the actionbar
    final ActionBar actionBar = getActionBar();
.
.
.

What do I have to do so that the real actionbar will be initialized without a small default one briefly showing before it does on startup?

Thanks

LoneDuck
  • 1,852
  • 1
  • 21
  • 28
  • 1
    Is this something you are looking for: [How to hide action bar before activity is created, and then show it again?](http://stackoverflow.com/questions/8500283/how-to-hide-action-bar-before-activity-is-created-and-then-show-it-again) – Paresh Mayani May 22 '13 at 04:55

3 Answers3

5

Hide during startup

 getSupportActionBar().hide();

After you can show it again with ...

 getSupportActionBar().show();

It should be the same with native ActionBar of Android.

you should use this line in manifest and don't use getActionBar()

<item name="android:windowActionBar">false</item>

and once it's finished in the main Activity use below or nothing

<item name="android:windowActionBar">true</item>
MBMJ
  • 5,323
  • 8
  • 32
  • 51
  • How do I add the XML you specified so that the app boots with false But then switches to true After the main activity starts? – LoneDuck Sep 18 '12 at 10:25
  • 1
    I've tried assigning the application itself a theme with no actionbar, but assign the activity with a theme with one (using android:windowActionBar). It still boots with a default actionbar, and only then initializes itself as the real navigation actionbar. – LoneDuck Sep 18 '12 at 14:35
  • http://stackoverflow.com/questions/8500283/how-to-hide-action-bar-before-activity-is-created-and-then-show-it-again?rq=1 watch this link – MBMJ Sep 19 '12 at 03:18
4

put this for your activity manifest definition:

 <activity
            android:name=".MyActivity"
             android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            >

then inside your oncreate do this to show the actual theme you want used:

setTheme(R.style.AppTheme); 
j2emanue
  • 60,549
  • 65
  • 286
  • 456
1

if you're using action bar sherlock and you want to toggle this from a FragmentActivity, then you call

getSherlockActivity().getSupportActionBar().hide();
Dhaval Parmar
  • 18,812
  • 8
  • 82
  • 177
kevinl
  • 4,194
  • 6
  • 37
  • 55