I\'ve been scouring the interwebs (e.g. Android documentation, answers here, etc.) for the answer to what I thought would be a fairly trivial question. How do you achieve a
If you want your activity to be fullscreen but still show an actionbar, but with an alpha you have to request overlaymode for the actionbar in onCreate()
of your activity:
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
//getWindow().requestFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY); << Use this for API 7+ (v7 support library)
Then after you call setContentView(..)
(since setContentView(..)
also initializes the actionbar next to setting the content) you can set a background drawable on your actionbar:
getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg));
which can be a shape drawable with an alpha put in res/drawable:
You could also do this completely programatically by creating a ColorDrawable
:
getActionBar().setBackgroundDrawable(new ColorDrawable(Color.argb(128, 0, 0, 0)));
Otherwise ofcourse you can hide the actionbar completely; in that case you can set a custom theme on your activity in your manifest:
@android:style/Theme.NoTitleBar.Fullscreen
or programmatically by calling
getActionBar().hide();