List of usage examples for android.app Activity getWindow
public Window getWindow()
From source file:edu.com.mvplibrary.ui.widget.StatusBarUtil.java
/** * DrawerLayout ???(5.0??,?)// www . ja va 2 s. c o m * * @param activity ?activity * @param drawerLayout DrawerLayout * @param color ?? */ public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout, int color) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // ???? View statusBarView = createStatusBarView(activity, color); // statusBarView ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); contentLayout.addView(statusBarView, 0); // ? LinearLayout ,padding top if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) { contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0); } // ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1); drawerLayout.setFitsSystemWindows(false); contentLayout.setFitsSystemWindows(false); contentLayout.setClipToPadding(true); drawer.setFitsSystemWindows(false); } }
From source file:com.xiaomi.account.utils.SysHelper.java
public static void blurWallpaper(Activity activity) { activity.getWindow().setBackgroundDrawable(WallpaperManager.getInstance(activity).getFastDrawable()); }
From source file:edu.com.mvplibrary.ui.widget.StatusBarUtil.java
/** * DrawerLayout ???(5.0??,?)/*from w ww . j a v a2s. co m*/ * * @param activity ?activity * @param drawerLayout DrawerLayout */ public static void setTranslucentForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // ??? activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); contentLayout.setFitsSystemWindows(true); contentLayout.setClipToPadding(true); // ViewGroup vg = (ViewGroup) drawerLayout.getChildAt(1); vg.setFitsSystemWindows(false); // DrawerLayout drawerLayout.setFitsSystemWindows(false); } }
From source file:com.gosuncn.core.util.view.StatusBarUtils.java
/** * ???/*from ww w .j a v a2s . com*/ * * @param activity activity * @return {@code true}: <br>{@code false}: ? */ public static boolean isStatusBarExists(Activity activity) { WindowManager.LayoutParams params = activity.getWindow().getAttributes(); return (params.flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != WindowManager.LayoutParams.FLAG_FULLSCREEN; }
From source file:com.gosuncn.core.util.view.StatusBarUtils.java
@TargetApi(Build.VERSION_CODES.KITKAT) private static void clearPreviousSetting(Activity activity) { ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); int count = decorView.getChildCount(); if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) { decorView.removeViewAt(count - 1); ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)) .getChildAt(0);/*www .j a va 2 s. co m*/ rootView.setPadding(0, 0, 0, 0); } }
From source file:com.gosuncn.core.util.view.StatusBarUtils.java
/** * ????/*from w w w . j av a2 s .c om*/ * <p>??setContentView??</p> * <p>Activity?AppCompatActivity</p> * <p>??????QQ?</p> * <p>?Activityandroid:theme="@android:style/Theme.NoTitleBar.Fullscreen"</p> * <p>?Activity?AppCompatActivity</p> * * @param activity activity */ public static void hideStatusBar(Activity activity) { activity.requestWindowFeature(Window.FEATURE_NO_TITLE); activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); }
From source file:com.gosuncn.core.util.view.StatusBarUtils.java
/** * ?//w ww .ja v a2 s . c o m */ private static void setTransparentForWindow(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().setStatusBarColor(Color.TRANSPARENT); activity.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } }
From source file:com.gosuncn.core.util.view.StatusBarUtils.java
/** * ???/*from w w w . ja v a 2s. c o m*/ */ @TargetApi(Build.VERSION_CODES.KITKAT) private static void transparentStatusBar(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); activity.getWindow().setStatusBarColor(Color.TRANSPARENT); } else { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } }
From source file:Main.java
public static void hideSmartBar(Activity activity) { if (!hasSmartBar()) return;// w ww .j ava 2 s . c o m try { @SuppressWarnings("rawtypes") Class[] arrayOfClass = new Class[1]; arrayOfClass[0] = Integer.TYPE; Method localMethod = View.class.getMethod("setSystemUiVisibility", arrayOfClass); Field localField = View.class.getField("SYSTEM_UI_FLAG_HIDE_NAVIGATION"); Object[] arrayOfObject = new Object[1]; try { arrayOfObject[0] = localField.get(null); } catch (Exception e) { } localMethod.invoke(activity.getWindow().getDecorView(), arrayOfObject); return; } catch (Exception e) { e.printStackTrace(); } }
From source file:com.ming.slove.mvnew.app.ThemeHelper.java
public static CardPickerDialog.ClickListener getCardPickerListener(final Context context) { return new CardPickerDialog.ClickListener() { @Override/* w ww . j av a2 s . c o m*/ public void onConfirm(int currentTheme) { if (ThemeHelper.getTheme(context) != currentTheme) { ThemeHelper.setTheme(context, currentTheme); ThemeUtils.refreshUI(context, new ThemeUtils.ExtraRefreshable() { @Override public void refreshGlobal(Activity activity) { if (Build.VERSION.SDK_INT >= 21) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription( null, null, ThemeUtils.getThemeAttrColor(context, android.R.attr.colorPrimary)); activity.setTaskDescription(taskDescription); activity.getWindow().setStatusBarColor( ThemeUtils.getColorById(context, R.color.theme_color_primary)); } } @Override public void refreshSpecificView(View view) { } }); //MainActivity? EventBus.getDefault().post(new ChangeThemeColorEvent()); } } }; }