List of usage examples for android.util DisplayMetrics DisplayMetrics
public DisplayMetrics()
From source file:Main.java
public static int getWidth(Activity activity) { if (mScreenWidth == 0) { DisplayMetrics dm = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); mScreenWidth = dm.widthPixels;/*w w w . j av a 2 s. c om*/ } return mScreenWidth; }
From source file:Main.java
public static float getDeviceDensity(Context context) { DisplayMetrics dMetrics = new DisplayMetrics(); WindowManager wManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wManager.getDefaultDisplay(); display.getMetrics(dMetrics);/*from w ww . j a v a 2 s . c o m*/ return dMetrics.density; }
From source file:Main.java
public static DisplayMetrics getScreenSize(Context context) { DisplayMetrics dMetrics = new DisplayMetrics(); WindowManager wManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wManager.getDefaultDisplay(); display.getMetrics(dMetrics);// w w w . j a v a 2s .co m return dMetrics; }
From source file:Main.java
public static int getScreenHeight(Activity activity) { if (mScreenHeight == 0) { DisplayMetrics dm = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); mScreenHeight = dm.heightPixels; }/* w ww.j a va 2 s . com*/ return mScreenHeight; }
From source file:Main.java
public static DisplayMetrics getScreenMetrics(Activity activity) { Display display = activity.getWindowManager().getDefaultDisplay(); DisplayMetrics outMetrics = new DisplayMetrics(); display.getMetrics(outMetrics);/*from w w w .j a v a 2 s . c om*/ return outMetrics; }
From source file:Main.java
public static int getWindowHeight(Activity activity) { if (mHeightPixels < 0) { DisplayMetrics dm = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); mWidthPixels = dm.widthPixels;//from ww w . j a v a 2 s . com mHeightPixels = dm.heightPixels; } return mHeightPixels; }
From source file:Main.java
/** * DisplayMetrics/*from w w w. j av a 2 s . c om*/ * * @return */ public static DisplayMetrics getDisplayMetrics(Context context) { DisplayMetrics displayMetrics = new DisplayMetrics(); ((WindowManager) context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics; }
From source file:Main.java
public static int getScreenWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); return dm.widthPixels; }
From source file:Main.java
public static int getWindowWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics metric = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(metric); return metric.widthPixels; }
From source file:Main.java
public static int getScreenWidth(Context mContext) { WindowManager manager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(dm); return dm.widthPixels; }