Android examples for User Interface:Window
set Window Brightness
//package com.java2s; import android.app.Activity; import android.view.Window; import android.view.WindowManager; public class Main { public static void setWindowBrightness(Activity activity, float screenBrightness) { float brightness = screenBrightness; if (screenBrightness < 1) { brightness = 1;//from w w w . jav a2 s . c o 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); } }