This is my code:
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
wm = (WindowManager) getApplicationContext()
.getSystemService(Context.WINDOW_SERVICE);
inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mTopView = (ViewGroup) inflater.inflate(R.layout.activity_invisible, null);
params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
| WindowManager.LayoutParams.FLAG_DIM_BEHIND
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_FULLSCREEN;
if (keep==true) {
int value = brightnessIntent.getExtras().getInt("value");
float v=value/255.0f;
params.dimAmount=0;
params.alpha=v;
rl = (RelativeLayout) mTopView.findViewById(R.id.window);
getWindow().setAttributes(params);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
wm.addView(mTopView, params);
}
The view still shows the status bar, mTopView
is an overlay window. How do I get the overlay window to cover the entire screen? I don't want to "hide" the status bar, I want my activity to overlay onto it.
[EDIT] emphasized text
I already have this in my onCreate()
method:
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
And my manifest defines a style which features fullscreen.
SCREENSHOTS
This is how it is currently, I want the overlay to extend to the status bar too.
All I had to do was this
params.flags=WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN| and the rest
This extends the overlay view over the status bar.
This code from "Android Application 4 Development". you have to handle different android versions
// Hiding the Action Bar for different android versions
if (Build.VERSION.SDK_INT < 16) {
// Hide the Action Bar on Android 4.0 and Lower
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}else {
// Hide the Action Bar on Android 4.1 and Higher
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
android.app.ActionBar actionBar = getActionBar();
actionBar.hide();
}
You can hide the status bar using two ways :
1) Define below line in your activity onCreate()
method.
requestWindowFeature(Window.FEATURE_NO_TITLE);
2)Define the theme at the application level not to show the status bar through out application as below:
<application android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With