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:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#BB000000" />
</shape>
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();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…