I want to have my custom layout action bar to be shown right as the activity starts,
Currently the default actionbar is shown for a second or two before I set the custom view for the action bar.
Currently i'm doing it this way :
actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(R.layout.actionbar);
And it works, but the default action bar is shown for a few seconds.
How can I set the custom xml layout as a style ?
Adding a FLAG_ACTIVITY_CLEAR_TOP before starting the intent has helped.
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
You have to add onemore line to you code.
ActionBar ab = getSupportActionBar();
ab.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
ab.setCustomView(R.layout.abs_title);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.