List of usage examples for android.app Activity getWindowManager
public WindowManager getWindowManager()
From source file:Main.java
public static int getScreenHeight(Activity activity) { Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); int height = 200; if (Build.VERSION.SDK_INT > 13) { display.getSize(size);/*from w w w . ja v a 2 s .com*/ height = size.y; } else { height = display.getHeight(); } return height; }
From source file:Main.java
public static int getScreenWidth(Activity activity) { Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); int width = 800; if (Build.VERSION.SDK_INT > 13) { display.getSize(size);//from w ww .j av a 2 s . co m width = size.x; } else { width = display.getWidth(); } return width; }
From source file:Main.java
public static Point getScreenSize(Activity activity) { Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size);//from w w w. j av a 2s .c om return size; }
From source file:Main.java
public static int getScreenHeightDP(Activity activity) { WindowManager wm = activity.getWindowManager(); //wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Display dp = wm.getDefaultDisplay(); DisplayMetrics dm = new DisplayMetrics(); dp.getMetrics(dm);/*from w ww. j a v a 2s . c om*/ float res = dm.heightPixels / dm.density; return (int) res; }
From source file:Main.java
public static int getScreenWidthDP(Activity activity) { WindowManager wm = activity.getWindowManager(); //wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Display dp = wm.getDefaultDisplay(); DisplayMetrics dm = new DisplayMetrics(); dp.getMetrics(dm);//w ww . j a va2 s . c o m float res = dm.widthPixels / dm.density; return (int) res; }
From source file:Main.java
public static Point getScreenSize(Activity context) { Point screenSize = new Point(); context.getWindowManager().getDefaultDisplay().getSize(screenSize); return screenSize; }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) public static void init2(Activity activity) { Point point = new Point(); activity.getWindowManager().getDefaultDisplay().getSize(point); }
From source file:Main.java
public static int getScreenOrientation(Activity activity) { Display getOrient = activity.getWindowManager().getDefaultDisplay(); int orientation = Configuration.ORIENTATION_UNDEFINED; if (getOrient.getWidth() == getOrient.getHeight()) { orientation = Configuration.ORIENTATION_SQUARE; } else {/*from w w w . ja v a2 s .com*/ if (getOrient.getWidth() < getOrient.getHeight()) { orientation = Configuration.ORIENTATION_PORTRAIT; } else { orientation = Configuration.ORIENTATION_LANDSCAPE; } } return orientation; }
From source file:Main.java
public static DisplayMetrics getDisplayMetrics(View view) { DisplayMetrics metrics = new DisplayMetrics(); Activity host = (Activity) view.getContext(); host.getWindowManager().getDefaultDisplay().getMetrics(metrics); return metrics; }
From source file:Main.java
/** * Get a value by percentage of the Screen. * * @param activity - Current Activity/* w w w . ja va 2 s . c o m*/ * @param value - The percentage * @return - A value represent the percentage */ public static int getYPercentageFromScreen(Activity activity, float value) { Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); return (int) (size.y * value) / 100; }