Example usage for android.util TypedValue COMPLEX_UNIT_DIP

List of usage examples for android.util TypedValue COMPLEX_UNIT_DIP

Introduction

In this page you can find the example usage for android.util TypedValue COMPLEX_UNIT_DIP.

Prototype

int COMPLEX_UNIT_DIP

To view the source code for android.util TypedValue COMPLEX_UNIT_DIP.

Click Source Link

Document

#TYPE_DIMENSION complex unit: Value is Device Independent Pixels.

Usage

From source file:Main.java

public static int dp2px(Context context, int dp) {
    return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
            context.getResources().getDisplayMetrics());
}

From source file:Main.java

public static float Dp2Px(Context context, float dpi) {
    return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpi,
            context.getResources().getDisplayMetrics());
}

From source file:Main.java

public static float dpToPx(Context context, float dp) {

    return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
            context.getResources().getDisplayMetrics());
}

From source file:Main.java

protected static int dpToPx(Context context, int dp) {
    return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
            context.getResources().getDisplayMetrics());
}

From source file:Main.java

public static int dipsToPix(Context ctx, float dps) {
    return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dps,
            ctx.getResources().getDisplayMetrics());
}

From source file:Main.java

public static int pxToDp(Context context, int px) {
    return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, px,
            context.getResources().getDisplayMetrics());
}

From source file:Main.java

public static float dp2px(float dp, Context context) {
    float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
            context.getResources().getDisplayMetrics());
    return px;/*from   w  ww  .j av  a2  s  .  c  o  m*/
}

From source file:Main.java

public static int dp2px(Context context, float dp) {
    return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
            context.getResources().getDisplayMetrics());
}

From source file:Main.java

public static float getPX(Context context, int dipValue) {
    return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue,
            context.getResources().getDisplayMetrics());
}

From source file:Main.java

public static float getPX(Context context, int dipValue) {
    return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30,
            context.getResources().getDisplayMetrics());
}