List of usage examples for android.view WindowManager getDefaultDisplay
public Display getDefaultDisplay();
From source file:Main.java
public static Rect getDisplaySize(Context context) { Rect rect = new Rect(); WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); rect.set(0, 0, display.getWidth(), display.getHeight()); return rect;/* ww w .j a va 2 s. c om*/ }
From source file:Main.java
public static boolean shouldScaleDownBitmap(Context context, Bitmap bitmap) { if (context != null && bitmap != null && bitmap.getWidth() > 0 && bitmap.getHeight() > 0) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics);/*w ww.j ava 2 s.c o m*/ int width = metrics.widthPixels; int height = metrics.heightPixels; return ((width != 0 && width / bitmap.getWidth() < 1) || (height != 0 && height / bitmap.getHeight() < 1)); } return false; }
From source file:Main.java
public static int[] getWindowSize(Context context) { final WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); final Display display = wm.getDefaultDisplay(); if (android.os.Build.VERSION.SDK_INT >= 13) { Point point = new Point(); display.getSize(point);/*from ww w .j a v a2s . co m*/ return new int[] { point.x, point.y }; } else { return new int[] { display.getWidth(), display.getHeight() }; } }
From source file:Main.java
public static Point getScreenSize(Context context) { WindowManager window = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = window.getDefaultDisplay(); Point size = new Point(); display.getSize(size);/*from w w w . j a va2 s .c o m*/ return size; }
From source file:Main.java
public static int getScreenWidth(Activity activity) { WindowManager manager = activity.getWindowManager(); DisplayMetrics outMetrics = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(outMetrics); // int height = outMetrics.heightPixels; int width2 = outMetrics.widthPixels; return width2; }
From source file:Main.java
public static Point getScreenDimensions(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point dimensions = new Point(); display.getSize(dimensions);// w w w . j av a 2 s . c o m return dimensions; }
From source file:Main.java
public static int getScreenHeight(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); Point point = new Point(); display.getSize(point);// w w w. j a va 2 s .c om return point.y; }
From source file:Main.java
public static int getScreenWidth(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); Point point = new Point(); display.getSize(point);// w w w. j a v a 2 s.co m return point.x; }
From source file:Main.java
public static int getScreenHeight(WindowManager windowManager) { if (screenHeight == null) { DisplayMetrics dm = new DisplayMetrics(); windowManager.getDefaultDisplay().getMetrics(dm); screenHeight = dm.heightPixels;// ww w. j av a 2 s.c o m } return screenHeight; }
From source file:Main.java
@SuppressWarnings("deprecation") @SuppressLint("NewApi") public static Point getScreenSize(Context mContext) { WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(size);/*from w ww.jav a2 s .c om*/ return size; } else { size.x = display.getWidth(); size.y = display.getHeight(); return size; } }