The solutions already posted came with the sideffect, that the first .show() call did not animate the ActionBar for me. I got another nice solution, which fixed that:
Create a transparent drawable - something like that:
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#00000000" /> </shape>
Set the actual actionbar background to a invisible custom view which you set on the actionbar:
getSupportActionBar().setCustomView(R.layout.actionbar_custom_layout); getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
Set the transparent background for the actionbar in onCreate:
getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.background_transparent));
Imortant: Don't hide the actionbar immediately in onCreate, but with a little delay later - e.g. when the layout is finished with creation:
getWindow().getDecorView().getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
getSupportActionBar().hide();
}
});
Before your first .show() call set the custom view visible:
_actionbarRoot.setVisibility(View.VISIBLE); getSupportActionBar().show();