List of usage examples for android.util DisplayMetrics DENSITY_DEFAULT
int DENSITY_DEFAULT
To view the source code for android.util DisplayMetrics DENSITY_DEFAULT.
Click Source Link
From source file:Main.java
public static int dpToPx(int dp, Context context) { DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); return Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); }
From source file:Main.java
public static int pxToDp(int px, Context context) { DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); return Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); }
From source file:Main.java
public static int dpToPx(Context context, int dp) { DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); return Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); }
From source file:Main.java
public static BitmapFactory.Options getBitmapOptions(DisplayMetrics mDisplayMetrics) { final BitmapFactory.Options options = new BitmapFactory.Options(); options.inDensity = DisplayMetrics.DENSITY_DEFAULT; options.inTargetDensity = mDisplayMetrics.densityDpi; return options; }
From source file:Main.java
public static double pxToDp(Context context, double px) { DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); double dp = Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); return dp;/*from w ww . j a v a2 s. com*/ }
From source file:Main.java
public static double dpToPx(Context context, double dp) { DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); double px = Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); return px;/* w ww . j av a 2 s.com*/ }
From source file:Main.java
public static Bitmap flipBitmap(Bitmap src) { Matrix m = new Matrix(); m.preScale(-1, 1);//from www . java 2 s . c o m Bitmap dst = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), m, false); dst.setDensity(DisplayMetrics.DENSITY_DEFAULT); return dst; }
From source file:Main.java
public static int dpToPx(Context mContext, int dp) { if (mContext == null) { return 0; }// www . j a va2 s. com DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics(); int px = Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); return px; }
From source file:Main.java
/** * Converts a size value in dp scale into pixel scale. *///from w w w .j ava 2 s . c om public static int dpToPx(Context context, int dp) { DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); int px = Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); return px; }
From source file:Main.java
/** * Converts a size value in pixel scale into dp scale. *///w ww.j a v a 2 s . c o m public static int pxToDp(Context context, int px) { DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); int dp = Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); return dp; }