List of usage examples for android.util TypedValue COMPLEX_UNIT_DIP
int COMPLEX_UNIT_DIP
To view the source code for android.util TypedValue COMPLEX_UNIT_DIP.
Click Source Link
From source file:Main.java
/** * dp2Px//from w ww .ja v a 2 s.c o m * * @param context context * @param dp dp * @return float */ public static float dp2Px(Context context, int dp) { return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics()); }
From source file:Main.java
/** * Converts the gives DPs into pixels for rendering on the screen correctly *//* ww w .j a va 2s .c o m*/ protected static int convertDipsToPixels(Context context, float dps) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dps, context.getResources().getDisplayMetrics()); }
From source file:Main.java
public static int getPixels(Context context, int dp) { DisplayMetrics metrics = context.getResources().getDisplayMetrics(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, metrics); }
From source file:Main.java
public static float dipToPixels(Context context, int dipValue) { DisplayMetrics metrics = context.getResources().getDisplayMetrics(); return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, metrics); }
From source file:Main.java
public static int getPixelSize(Context context, int dip) { DisplayMetrics metrics = context.getResources().getDisplayMetrics(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, metrics); }
From source file:Main.java
public static int dpToPixels(int dp) { DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics(); return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, displayMetrics)); //return Math.round(dp * Resources.getSystem().getDisplayMetrics().density); }
From source file:Main.java
/** * Converteert DIP naar het bijbehorend aantal pixels * @param c// w w w .j ava 2 s.c om * @param dip * @return */ public static int DIPtoPX(Context c, int dip) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, c.getResources().getDisplayMetrics()); }
From source file:Main.java
public static int dip2px(Context context, float dp) { Resources r = context.getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); return Math.round(px); }
From source file:Main.java
public static int getPixels(Context context, int dipValue) { Resources r = context.getResources(); int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, r.getDisplayMetrics()); Log.d("getPixels", "" + px); return px;//from w w w .j a va2 s. c o m }
From source file:Main.java
/** dip to px */ public static int dip2px(Context context, int dip) { int finalPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, context.getResources().getDisplayMetrics()); // final float scale = context.getResources().getDisplayMetrics().density; // return (int) (dip * scale + 0.5f); return finalPx; }