List of usage examples for android.view Window setAttributes
public void setAttributes(WindowManager.LayoutParams a)
From source file:Main.java
public static void showAsPopup(Activity activity) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { return;//w w w. j a v a2s. c o m } activity.requestWindowFeature(Window.FEATURE_ACTION_BAR); //To show activity as dialog and dim the background, you need to declare android:theme="@style/PopupTheme" on for the chosen activity on the manifest Window window = activity.getWindow(); window.setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND); Display display = activity.getWindowManager().getDefaultDisplay(); WindowManager.LayoutParams params = window.getAttributes(); params.height = (int) (display.getHeight() * 0.95); params.width = Math.min((int) (display.getWidth() * 0.9), (int) (params.height * 0.85)); params.gravity = Gravity.BOTTOM; params.alpha = 1.0f; params.dimAmount = 0.5f; window.setAttributes(params); }
From source file:Main.java
public static boolean setStatusBarDarkIcon(Window window, boolean dark) { boolean result = false; if (window != null) { try {// w w w.ja va2 s.c o m WindowManager.LayoutParams lp = window.getAttributes(); Field darkFlag = WindowManager.LayoutParams.class .getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON"); Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags"); darkFlag.setAccessible(true); meizuFlags.setAccessible(true); int bit = darkFlag.getInt(null); int value = meizuFlags.getInt(lp); if (dark) { value |= bit; } else { value &= ~bit; } meizuFlags.setInt(lp, value); window.setAttributes(lp); result = true; } catch (Exception ignored) { } } return result; }
From source file:Main.java
/** * meizu Flyme set status bar light mode *///w w w . j a v a2 s .co m public static boolean FlymeSetStatusBarLightMode(Window window, boolean dark) { boolean result = false; if (window != null) { try { WindowManager.LayoutParams lp = window.getAttributes(); Field darkFlag = WindowManager.LayoutParams.class .getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON"); Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags"); darkFlag.setAccessible(true); meizuFlags.setAccessible(true); int bit = darkFlag.getInt(null); int value = meizuFlags.getInt(lp); if (dark) { value |= bit; } else { value &= ~bit; } meizuFlags.setInt(lp, value); window.setAttributes(lp); result = true; } catch (Exception e) { } } return result; }
From source file:com.almalence.util.Util.java
public static void enterLightsOutMode(Window window) { WindowManager.LayoutParams params = window.getAttributes(); window.setAttributes(params); }
From source file:com.almalence.opencam.Fragment.java
public static void setScreenBrightness(boolean setMax) { try {/* ww w .j av a 2s . co m*/ Window window = thiz.getActivity().getWindow(); WindowManager.LayoutParams layoutpars = window.getAttributes(); // Set the brightness of this window if (setMax) layoutpars.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL; else layoutpars.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE; // Apply attribute changes to this window window.setAttributes(layoutpars); } catch (Exception e) { } }
From source file:com.cardvlaue.sys.util.ScreenUtil.java
/** * ???Flyme4.0 ???Flyme/*from ww w.j a v a 2 s. c o m*/ * * @param window ?? * @param dark ???? * @return boolean ?true */ public static boolean FlymeSetStatusBarLightMode(Window window, boolean dark) { boolean result = false; if (window != null) { try { WindowManager.LayoutParams lp = window.getAttributes(); Field darkFlag = WindowManager.LayoutParams.class .getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON"); Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags"); darkFlag.setAccessible(true); meizuFlags.setAccessible(true); int bit = darkFlag.getInt(null); int value = meizuFlags.getInt(lp); if (dark) { value |= bit; } else { value &= ~bit; } meizuFlags.setInt(lp, value); window.setAttributes(lp); result = true; } catch (Exception e) { // e.printStackTrace(); } } return result; }
From source file:com.github.piasy.chatrecyclerview.example.InputDialog.java
@Override public void onStart() { super.onStart(); // without title and title divider // Less dimmed background; see http://stackoverflow.com/q/13822842/56285 Window window = getDialog().getWindow(); WindowManager.LayoutParams params = window.getAttributes(); //CHECKSTYLE:OFF params.dimAmount = 0;/*from w w w .j ava 2 s .c o m*/ //CHECKSTYLE:ON window.setAttributes(params); window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); window.setGravity(Gravity.BOTTOM); // Transparent background; see http://stackoverflow.com/q/15007272/56285 // (Needed to make dialog's alpha shadow look good) window.setBackgroundDrawableResource(android.R.color.transparent); final Resources res = getResources(); final int titleDividerId = res.getIdentifier("titleDivider", "id", "android"); if (titleDividerId > 0) { final View titleDivider = getDialog().findViewById(titleDividerId); if (titleDivider != null) { titleDivider.setBackgroundColor(res.getColor(android.R.color.transparent)); } } }
From source file:com.esminis.server.library.dialog.about.AboutViewImpl.java
@Override public void setupOnCreate() { final Window window = getWindow(); final WindowManager.LayoutParams params = window.getAttributes(); params.width = getContext().getResources().getDimensionPixelSize(R.dimen.about_dialog_width); params.height = ViewGroup.LayoutParams.WRAP_CONTENT; window.setAttributes(params); }
From source file:com.seongil.simpleavatarpicker.demo.PictureChooserDialog.java
@Override public void onResume() { Window window = getDialog().getWindow(); if (window != null) { ViewGroup.LayoutParams params = window.getAttributes(); params.width = ViewGroup.LayoutParams.WRAP_CONTENT; params.height = ViewGroup.LayoutParams.WRAP_CONTENT; window.setAttributes((android.view.WindowManager.LayoutParams) params); }/*from ww w .j a v a 2s. co m*/ super.onResume(); }
From source file:com.github.michaelins.lightstatusbar.LightStatusBar.java
@TargetApi(Build.VERSION_CODES.KITKAT) private void setTranslucentStatus(Window win, boolean on) { WindowManager.LayoutParams winParams = win.getAttributes(); final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; if (on) {//w w w . ja v a2s . com winParams.flags |= bits; } else { winParams.flags &= ~bits; } win.setAttributes(winParams); }