Example usage for android.view Window setAttributes

List of usage examples for android.view Window setAttributes

Introduction

In this page you can find the example usage for android.view Window setAttributes.

Prototype

public void setAttributes(WindowManager.LayoutParams a) 

Source Link

Document

Specify custom window attributes.

Usage

From source file:Main.java

public static void setTranslucentStatus(Activity activity, boolean on) {
    Window win = activity.getWindow();
    WindowManager.LayoutParams winParams = win.getAttributes();
    win.setAttributes(winParams);
}

From source file:Main.java

/**
 * Set the screen's brightness level.//from w w  w .  jav a2s . c  o  m
 *
 * @param window
 * @param brightness
 */
public static void setBrightness(Window window, float brightness) {
    WindowManager.LayoutParams layout = window.getAttributes();
    layout.screenBrightness = brightness;
    window.setAttributes(layout);
}

From source file:Main.java

public static void enterLightsOutMode(Window window) {
    WindowManager.LayoutParams params = window.getAttributes();
    params.systemUiVisibility = View.SYSTEM_UI_FLAG_LOW_PROFILE;
    window.setAttributes(params);
}

From source file:Main.java

public static void setFullScreen(Activity activity) {
    activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
    Window window = activity.getWindow();
    WindowManager.LayoutParams params = window.getAttributes();
    params.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
    window.setAttributes(params);
    window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}

From source file:Main.java

/**
 * @param pActivity/*w  w w .ja  v  a  2  s  .c o m*/
 * @param pScreenBrightness [0..1]
 */
public static void setScreenBrightness(final Activity pActivity, final float pScreenBrightness) {
    final Window window = pActivity.getWindow();
    final WindowManager.LayoutParams windowLayoutParams = window.getAttributes();
    windowLayoutParams.screenBrightness = pScreenBrightness;
    window.setAttributes(windowLayoutParams);
}

From source file:Main.java

public static void setScreenBrightness(int paramInt, Activity context) {
    Window localWindow = context.getWindow();
    WindowManager.LayoutParams localLayoutParams = localWindow.getAttributes();
    float f = paramInt / 255.0F;
    localLayoutParams.screenBrightness = f;
    localWindow.setAttributes(localLayoutParams);
}

From source file:Main.java

public static void setFullScreen(Activity activity, boolean isFull) {
    Window window = activity.getWindow();
    WindowManager.LayoutParams params = window.getAttributes();
    if (isFull) {
        params.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
        window.setAttributes(params);
        window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    } else {/*www .j a  v  a 2  s .c  o m*/
        params.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
        window.setAttributes(params);
        window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    }
}

From source file:Main.java

public static void setWindowBrightness(Activity activity, float screenBrightness) {
    float brightness = screenBrightness;
    if (screenBrightness < 1) {
        brightness = 1;/*from ww  w .jav  a2s .  co m*/
    } else if (screenBrightness > 255) {
        brightness = screenBrightness % 255;
        if (brightness == 0) {
            brightness = 255;
        }
    }
    Window window = activity.getWindow();
    WindowManager.LayoutParams localLayoutParams = window.getAttributes();
    localLayoutParams.screenBrightness = (float) brightness / 255;
    window.setAttributes(localLayoutParams);
}

From source file:Main.java

public static void setScreenBrightness(int paramInt, Activity mActivity) {
    if (paramInt <= 5) {
        paramInt = 5;/*from www.  jav a 2  s  . c  o  m*/
    }
    Window localWindow = mActivity.getWindow();
    WindowManager.LayoutParams localLayoutParams = localWindow.getAttributes();
    float f = paramInt / 100.0F;
    localLayoutParams.screenBrightness = f;
    localWindow.setAttributes(localLayoutParams);
}

From source file:Main.java

private static void setTranslucentStatus(Activity context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window win = context.getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        winParams.flags |= bits;//from www.  j  a va  2  s. c  o  m
        win.setAttributes(winParams);
    }

}