Android- hide actionbar during startup and then sh

2019-04-21 11:21发布

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

3条回答
Luminary・发光体
2楼-- · 2019-04-21 11:47

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

getSherlockActivity().getSupportActionBar().hide();
查看更多
疯言疯语
3楼-- · 2019-04-21 11:50

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); 
查看更多
做自己的国王
4楼-- · 2019-04-21 11:59

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>
查看更多
登录 后发表回答