List of usage examples for android.util TypedValue applyDimension
public static float applyDimension(int unit, float value, DisplayMetrics metrics)
From source file:Main.java
public static int typeValueToSp(Context context, int sp) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, context.getResources().getDisplayMetrics()); }
From source file:Main.java
public static float dipToPx(Resources res, float dip) { float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, res.getDisplayMetrics()); return px;//from ww w . j a va 2 s . c o m }
From source file:Main.java
public static float dp2px(Resources resources, float dp) { float v = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics()); return (int) (v + 0.5f); }
From source file:Main.java
public static int pixelsToDpi(Resources resources, int i) { return (int) TypedValue.applyDimension(1, (float) i, resources.getDisplayMetrics()); }
From source file:Main.java
static public int getPixelFromDip(DisplayMetrics dm, float dip) { return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, dm) + 0.5f); }
From source file:Main.java
public static int getSpToPx(Resources res, int dip) { int pixel = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, dip, res.getDisplayMetrics()); return pixel; }
From source file:Main.java
public static int getDipToPx(Resources res, int dip) { int pixel = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, res.getDisplayMetrics()); return pixel; }
From source file:Main.java
public static int convertDPIntoPixel(int dp, Context context) { int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics()); return px;/* ww w.j a v a 2 s . c om*/ }
From source file:Main.java
public static int changeUnit(Context context, int unit, float value) { return (int) TypedValue.applyDimension(unit, value, context.getResources().getDisplayMetrics()); }
From source file:Main.java
public static int sp2px(int spValue, DisplayMetrics displayMetrics) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, spValue, displayMetrics); }