List of usage examples for android.app Activity getWindow
public Window getWindow()
From source file:edu.com.mvplibrary.ui.widget.StatusBarUtil.java
/** * DrawerLayout ???/*from w w w. jav a2 s . c o m*/ * * @param activity ?activity * @param drawerLayout DrawerLayout */ public static void setTransparentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); activity.getWindow().setStatusBarColor(Color.TRANSPARENT); } else { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(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:by.gdgminsk.animationguide.util.AnimUtils.java
@SuppressWarnings("unchecked") public static ActivityOptionsCompat makeSharedViewOptions(Activity activity, View... views) { List<Pair<View, String>> sharedPairs = new ArrayList<>(); for (View view : views) { sharedPairs.add(new Pair<>(view, ViewCompat.getTransitionName(view))); }/*from w w w . j a v a2s .c o m*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // always add status bar and navigation bar to shared element transition to play shared views animation // without UI glitch described here https://plus.google.com/+AlexLockwood/posts/RPtwZ5nNebb View decor = activity.getWindow().getDecorView(); View statusBar = decor.findViewById(android.R.id.statusBarBackground); if (statusBar != null) { sharedPairs.add(new Pair<>(statusBar, ViewCompat.getTransitionName(statusBar))); } View navBar = decor.findViewById(android.R.id.navigationBarBackground); if (navBar != null) { sharedPairs.add(new Pair<>(navBar, ViewCompat.getTransitionName(navBar))); } } return ActivityOptionsCompat.makeSceneTransitionAnimation(activity, sharedPairs.toArray(new Pair[sharedPairs.size()])); }
From source file:com.gosuncn.core.util.view.StatusBarUtils.java
/** * ??/* w w w . j av a 2 s. co m*/ * * @param activity ?activity * @param color ?? * @param statusBarAlpha ??? */ public static void setColor(Activity activity, int color, int statusBarAlpha) { 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().setStatusBarColor(calculateStatusColor(color, statusBarAlpha)); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); int count = decorView.getChildCount(); if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) { decorView.getChildAt(count - 1).setBackgroundColor(calculateStatusColor(color, statusBarAlpha)); } else { StatusBarView statusView = createStatusBarView(activity, color, statusBarAlpha); decorView.addView(statusView); } setRootView(activity); } }
From source file:edu.com.mvplibrary.ui.widget.StatusBarUtil.java
/** * DrawerLayout ???/*from ww w . j a v a 2 s. com*/ * * @param activity ?activity * @param drawerLayout DrawerLayout * @param color ?? * @param statusBarAlpha ??? */ public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, int color, int statusBarAlpha) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); activity.getWindow().setStatusBarColor(Color.TRANSPARENT); } else { 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); addTranslucentView(activity, statusBarAlpha); }
From source file:org.huxizhijian.sdk.util.StatusBarUtil.java
/** * ???API16/*from w w w. jav a 2 s. c o m*/ * * @param activity */ public static void showStatusBar(Activity activity) { if (Build.VERSION.SDK_INT < 16) { activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } else { View decorView = activity.getWindow().getDecorView(); // Show Status Bar. int uiOptions = View.SYSTEM_UI_FLAG_VISIBLE; decorView.setSystemUiVisibility(uiOptions); } }
From source file:org.huxizhijian.sdk.util.StatusBarUtil.java
/** * ??API16/*from w w w. jav a 2s . c om*/ * * @param activity */ public static void hideStatusBar(Activity activity) { if (Build.VERSION.SDK_INT < 16) { activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else { View decorView = activity.getWindow().getDecorView(); // Hide Status Bar. int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(uiOptions); } }
From source file:Main.java
public static void startActivity(final Activity thisActivity, final Intent intent, final View triggerView, int colorOrImageRes, final long durationMills) { int[] location = new int[2]; triggerView.getLocationInWindow(location); final int cx = location[0] + triggerView.getWidth(); final int cy = location[1] + triggerView.getHeight() + (int) TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 160, thisActivity.getResources().getDisplayMetrics()); final ImageView view = new ImageView(thisActivity); view.setScaleType(ImageView.ScaleType.CENTER_CROP); view.setImageResource(colorOrImageRes); final ViewGroup decorView = (ViewGroup) thisActivity.getWindow().getDecorView(); int w = decorView.getWidth(); int h = decorView.getHeight(); decorView.addView(view, w, h);//from www . ja va 2s. c o m final int finalRadius = (int) Math.sqrt(w * w + h * h) + 1; Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius); anim.setDuration(durationMills); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); thisActivity.startActivity(intent); thisActivity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); } }); anim.start(); }
From source file:com.bilibili.magicasakura.utils.ThemeUtils.java
public static void refreshUI(Context context, ExtraRefreshable extraRefreshable) { TintManager.clearTintCache();/*w ww . jav a 2s. c o m*/ Activity activity = getWrapperActivity(context); if (activity != null) { if (extraRefreshable != null) { extraRefreshable.refreshGlobal(activity); } View rootView = activity.getWindow().getDecorView().findViewById(android.R.id.content); refreshView(rootView, extraRefreshable); } }
From source file:org.huxizhijian.sdk.util.StatusBarUtil.java
public static void setFullScreen(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = activity.getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); window.getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // ???,? ContentView ? activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); }/*from w ww . java 2 s .co m*/ }
From source file:com.gosuncn.core.util.view.StatusBarUtils.java
/** * DrawerLayout ???/*from w ww. j av a 2 s.c o m*/ * * @param activity ?activity * @param drawerLayout DrawerLayout */ public static void setTransparentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return; } 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().setStatusBarColor(Color.TRANSPARENT); } else { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(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); }