List of usage examples for android.view WindowManager getDefaultDisplay
public Display getDefaultDisplay();
From source file:Main.java
public static int getScreenWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);/*from w ww. j ava 2 s .co m*/ return size.x; }
From source file:Main.java
public static float getScreenDensity(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics);/*from w w w . j av a 2s . c om*/ return metrics.density; }
From source file:Main.java
public static float getScreenWidthPPI(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics outMetrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(outMetrics); return outMetrics.xdpi; }
From source file:Main.java
public static float sizeYByX(WindowManager windowManager, float baseY, float basex, int exceptDis) { final Display display = windowManager.getDefaultDisplay(); Point mPoint = new Point(); getSize(display, mPoint);/*from w w w. j av a 2 s. co m*/ if (exceptDis > mPoint.x) { return 0.0f; } float displayWidth = mPoint.x - exceptDis; float scaleX = displayWidth / basex; return baseY * scaleX; }
From source file:Main.java
/** * @param context//from ww w. jav a 2 s . com * @return DisplayMetrics. */ public static DisplayMetrics getDisplayMetrics(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics metrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(metrics); return metrics; }
From source file:Main.java
public static int getScreenWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics outMetrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(outMetrics); int width = outMetrics.widthPixels; return width; }
From source file:Main.java
public static Point getScreenSize(Context applicationContext) { WindowManager wm = (WindowManager) applicationContext.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 . j a va2 s .c om else { size.x = display.getWidth(); size.y = display.getHeight(); } return size; }
From source file:Main.java
@SuppressWarnings("deprecation") public static int getScreenHeight(Activity activity) { int Measuredheight = 0; Point size = new Point(); WindowManager wm = activity.getWindowManager(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { wm.getDefaultDisplay().getSize(size); Measuredheight = size.y;/*from ww w . j a v a 2 s .c o m*/ } else { Display d = wm.getDefaultDisplay(); Measuredheight = d.getWidth(); } return Measuredheight; }
From source file:Main.java
public static int getScreenHeight(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics outMetrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(outMetrics); int height = outMetrics.heightPixels; return height; }
From source file:Main.java
@SuppressWarnings("deprecation") public static int getScreenWidth(Activity activity) { int Measuredwidth = 0; Point size = new Point(); WindowManager wm = activity.getWindowManager(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { wm.getDefaultDisplay().getSize(size); Measuredwidth = size.x;//from ww w. j a v a2 s . c om } else { Display d = wm.getDefaultDisplay(); Measuredwidth = d.getWidth(); } return Measuredwidth; }