Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fullscreen in WindowManager

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.

like image 360
Karthik Balakrishnan Avatar asked Jan 18 '13 11:01

Karthik Balakrishnan


3 Answers

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.

like image 66
Karthik Balakrishnan Avatar answered Oct 16 '22 16:10

Karthik Balakrishnan


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();
     }
like image 40
Bahi Hussein Avatar answered Oct 16 '22 17:10

Bahi Hussein


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">
like image 30
GrIsHu Avatar answered Oct 16 '22 17:10

GrIsHu