Fullscreen in WindowManager

Karthik Balakrishnan picture Karthik Balakrishnan · Jan 18, 2013 · Viewed 33.1k times · Source

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

enter image description here

This is how it is currently, I want the overlay to extend to the status bar too.

Answer

Karthik Balakrishnan picture Karthik Balakrishnan · Jan 18, 2013

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.