List of usage examples for android.app Activity getWindow
public Window getWindow()
From source file:org.huxizhijian.sdk.util.StatusBarUtil.java
/** * ???(5.0??,?)/*from w w w. j a va 2s.co m*/ * <p> * ?,??? * * @param activity ?activity */ @Deprecated public static void setTranslucentDiff(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // ??? activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); setRootView(activity); } }
From source file:org.proninyaroslav.libretorrent.core.utils.Utils.java
public static void showActionModeStatusBar(Activity activity, boolean mode) { int color = (mode ? R.color.action_mode_dark : R.color.primary_dark); if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { RelativeLayout statusBar = (RelativeLayout) activity.findViewById(R.id.statusBarKitKat); statusBar.setBackground(ContextCompat.getDrawable(activity, color)); statusBar.setVisibility(View.VISIBLE); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().setStatusBarColor(ContextCompat.getColor(activity, color)); }/*from w w w .j a v a2s . co m*/ }
From source file:free.yhc.netmbuddy.utils.Utils.java
public static Rect getVisibleFrame(Activity activity) { Rect rect = new Rect(); Window window = activity.getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(rect); return rect;//from www. j av a 2 s . c o m }
From source file:org.huxizhijian.sdk.util.StatusBarUtil.java
/** * ??//from w w w.j a v a 2 s . c om * * @param activity ?activity * @param color ?? * @param statusBarAlpha ??? */ public static void setColor(Activity activity, @ColorInt 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:org.huxizhijian.sdk.util.StatusBarUtil.java
/** * ??(5.0??,?)//w w w . j a v a 2 s . c om * * @param activity ? activity * @param color ?? */ @Deprecated public static void setColorDiff(Activity activity, @ColorInt int color) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return; } 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(color); } else { StatusBarView statusView = createStatusBarView(activity, color); decorView.addView(statusView); } setRootView(activity); }
From source file:free.yhc.netmbuddy.utils.Utils.java
/** * Only available when status bar is showing. * @param activity// ww w . ja v a2 s .c o m * @return */ public static int getStatusBarHeight(Activity activity) { Rect rect = new Rect(); Window window = activity.getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(rect); // Below is for future reference. // int StatusBarHeight = rect.top; // int contentViewTop = window.findViewById(Window.ID_ANDROID_CONTENT).getTop(); // int TitleBarHeight= contentViewTop - StatusBarHeight; return rect.top; }
From source file:org.huxizhijian.sdk.util.StatusBarUtil.java
/** * DrawerLayout ???(5.0??,?)//from www . j a v a2 s. co m * * @param activity ?activity * @param drawerLayout DrawerLayout */ @Deprecated 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:org.huxizhijian.sdk.util.StatusBarUtil.java
/** * DrawerLayout ???(5.0??,?)//from w ww. j a v a 2s. co m * * @param activity ?activity * @param drawerLayout DrawerLayout * @param color ?? */ @Deprecated public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // ???? ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); if (contentLayout.getChildCount() > 0 && contentLayout.getChildAt(0) instanceof StatusBarView) { contentLayout.getChildAt(0) .setBackgroundColor(calculateStatusColor(color, DEFAULT_STATUS_BAR_ALPHA)); } else { // statusBarView StatusBarView statusBarView = createStatusBarView(activity, color); 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:org.huxizhijian.sdk.util.StatusBarUtil.java
public static void setTranslucentImageHeader(Activity activity, int alpha, View needOffsetView) { setFullScreen(activity);/*from w w w . ja v a 2 s.c o m*/ //?windowphonedecorView ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); int count = decorView.getChildCount(); //??statusBarView if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) { decorView.getChildAt(count - 1).setBackgroundColor(Color.argb(alpha, 0, 0, 0)); } else { //??view StatusBarView statusView = createTranslucentStatusBarView(activity, alpha); decorView.addView(statusView); } if (needOffsetView != null) { ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) needOffsetView .getLayoutParams(); layoutParams.setMargins(0, getStatusBarHeight(activity), 0, 0); } }
From source file:ameircom.keymedia.Activity.transition.FabTransform.java
/** * Create a {@link FabTransform} from the supplied {@code activity} extras and set as its * shared element enter/return transition. *///from ww w . jav a 2 s .c om public static boolean setup(@NonNull Activity activity, @Nullable View target) { final Intent intent = activity.getIntent(); if (!intent.hasExtra(EXTRA_FAB_COLOR) || !intent.hasExtra(EXTRA_FAB_ICON_RES_ID)) { return false; } final int color = intent.getIntExtra(EXTRA_FAB_COLOR, Color.TRANSPARENT); final int icon = intent.getIntExtra(EXTRA_FAB_ICON_RES_ID, -1); final FabTransform sharedEnter = new FabTransform(color, icon); if (target != null) { sharedEnter.addTarget(target); } activity.getWindow().setSharedElementEnterTransition(sharedEnter); return true; }