List of usage examples for android.app Activity getWindow
public Window getWindow()
From source file:Main.java
/** * set no title and no status bar/*from w w w.j a v a 2s . c o m*/ * * @param activity */ public static void setNoTitleAndNoStatusBarScreen(Activity activity) { activity.requestWindowFeature(Window.FEATURE_NO_TITLE); activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); }
From source file:Main.java
public static void setTranslucent(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); }/*from w w w . jav a2 s . c o m*/ }
From source file:Main.java
private static boolean setMiuiStatusBarDarkMode(Activity activity, boolean darkmode) { Class<? extends Window> clazz = activity.getWindow().getClass(); try {//from w ww .j a v a 2 s. co m int darkModeFlag = 0; Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams"); Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE"); darkModeFlag = field.getInt(layoutParams); Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class); extraFlagField.invoke(activity.getWindow(), darkmode ? darkModeFlag : 0, darkModeFlag); return true; } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:Main.java
public static int[] sizeWithTitle(Activity activity) { Rect outRect = new Rect(); int[] size = new int[2]; activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect); size[0] = outRect.width();/*w w w. j a v a 2s .c o m*/ size[1] = outRect.height(); return size; }
From source file:Main.java
public static int[] sizeActivity(Activity activity) { int[] size = new int[2]; Rect outRect = new Rect(); activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getDrawingRect(outRect); size[0] = outRect.width();/* w w w.j ava 2 s . com*/ size[1] = outRect.height(); return size; }
From source file:Main.java
public static int getNotifyBarHeight(Activity context) { Rect frame;//from ww w .ja v a 2s .c o m try { frame = new Rect(); context.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); return frame.top; } catch (Exception e) { e.printStackTrace(); } return 0; }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static void forceRTLIfSupported(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { activity.getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL); }//w w w . ja v a 2 s. c o m }
From source file:Main.java
public static void setColor(Activity activity, int color) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().setStatusBarColor(color); }//from w w w .j av a2 s .c om }
From source file:Main.java
public static void setPureColor(Activity activity, int color) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().setStatusBarColor(color); }//from ww w .j a v a 2 s .co m }
From source file:Main.java
/** * get status bar height.//from w w w . ja va 2s. c o m * <br /> * rely on the fact that te status bar is shown at the time you make your computation, * <strong> * getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN) * this will not work!! * </strong> * * @param activity * @return */ public static int getStatusBarHeight(Activity activity) { Rect frame = new Rect(); activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); return frame.top; }