Example usage for android.app Activity getWindow

List of usage examples for android.app Activity getWindow

Introduction

In this page you can find the example usage for android.app Activity getWindow.

Prototype

public Window getWindow() 

Source Link

Document

Retrieve the current android.view.Window for the activity.

Usage

From source file:Main.java

public static void ajustWindow(Activity act, float alpha) {
    WindowManager.LayoutParams lp = act.getWindow().getAttributes();
    lp.alpha = alpha;//  w  w  w  .ja va2s . c om
    act.getWindow().setAttributes(lp);
}

From source file:Main.java

@TargetApi(19)
public static void setTranslucentStatus(Activity activity, boolean on) {
    Window win = activity.getWindow();
    WindowManager.LayoutParams winParams = win.getAttributes();
    final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
    if (on) {/*from   ww w . j  ava 2s.  c  om*/
        winParams.flags |= bits;
    } else {
        winParams.flags &= ~bits;
    }
    win.setAttributes(winParams);
}

From source file:Main.java

@TargetApi(19)
public static void setTranslucentNavigation(Activity activity, boolean on) {
    Window win = activity.getWindow();
    WindowManager.LayoutParams winParams = win.getAttributes();
    final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
    if (on) {/*  w ww  . j  a  v a2  s . c om*/
        winParams.flags |= bits;
    } else {
        winParams.flags &= ~bits;
    }
    win.setAttributes(winParams);
}

From source file:Main.java

public static void quitFullScreen(Activity activity) {
    final WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
    attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
    activity.getWindow().setAttributes(attrs);
    activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}

From source file:Main.java

/**
 * Returns the view container for the ActionBar.
 *
 * @return/*from   w ww.j  a va2 s.c o m*/
 */
public static View getActionBarView(Activity activity) {
    Window window = activity.getWindow();
    View view = window.getDecorView();
    int resId = activity.getResources().getIdentifier("action_bar_container", "id", "android");

    return view.findViewById(resId);
}

From source file:Main.java

public static Rect getAppMatchWidthHeight(Activity activity) {
    Rect appMatchRect = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(appMatchRect);
    return appMatchRect;
}

From source file:Main.java

public static int getTitleBarHeight(Activity activity) {
    Rect rect = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
    int sbh = rect.top;
    int contentTop = activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop();
    int titleBarTop = contentTop - sbh;
    return titleBarTop;
}

From source file:Main.java

public static void changeScreen(Activity ctx, float f) {

    WindowManager.LayoutParams lp = ctx.getWindow().getAttributes();
    lp.alpha = f;//  w w  w .j a va 2s. c  o  m
    lp.dimAmount = f;
    ctx.getWindow().setAttributes(lp);

}

From source file:Main.java

public static Rect getAppWrapWidthHeight(Activity activity) {
    Rect appWrapRect = new Rect();
    activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getDrawingRect(appWrapRect);
    return appWrapRect;
}

From source file:Main.java

public static int[] getApplicationWidthAndHeight(Activity activity) {
    Rect outRect = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect);
    System.out.println("top:" + outRect.top + " ; left: " + outRect.left);
    int info[] = new int[2];
    info[0] = outRect.width();//from   ww w.j ava2 s.co m
    info[1] = outRect.height();
    return info;
}