List of usage examples for android.content.res Resources getSystem
public static Resources getSystem()
From source file:Main.java
public static int getStatusBarHeight() { int result = 0; int resourceId = Resources.getSystem().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { result = Resources.getSystem().getDimensionPixelSize(resourceId); }// w w w . jav a 2s . c o m return result; }
From source file:Main.java
public static int getNavigationBarHeight() { int result = 0; int resourceId = Resources.getSystem().getIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { result = Resources.getSystem().getDimensionPixelSize(resourceId); }//from w w w . ja v a 2s. c o m return result; }
From source file:Main.java
public static DisplayMetrics getDisplayMetrics() { return Resources.getSystem().getDisplayMetrics(); }
From source file:Main.java
public static float getDpFromPixels(int px) { return px / Resources.getSystem().getDisplayMetrics().density; }
From source file:Main.java
public static float getPixelsFromDp(int dp) { return dp * Resources.getSystem().getDisplayMetrics().density; }
From source file:Main.java
public static int dpToPx(int dp) { return (int) (dp * Resources.getSystem().getDisplayMetrics().density); }
From source file:Main.java
public static float pxToDp(float pixels) { DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics(); return pixels / (metrics.densityDpi / 160f); }
From source file:Main.java
public static int ConvertToDp(int px) { DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics(); float dp = px / (metrics.densityDpi / 160f); return Math.round(dp); }
From source file:Main.java
public static int dp2px(final float dpValue) { final float density = Resources.getSystem().getDisplayMetrics().density; return (int) (dpValue * density + 0.5f); }
From source file:Main.java
public static int px2dip(final float pxValue) { final float density = Resources.getSystem().getDisplayMetrics().density; return (int) (pxValue / density + 0.5f); }