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 float dip2pxF(Context context, float dp) {
    return convertUnitToPixel(context, TypedValue.COMPLEX_UNIT_DIP, dp);
}

From source file:Main.java

private 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 float dip2px(Context context, float value) {
    return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value,
            context.getResources().getDisplayMetrics());
}

From source file:Main.java

public static int dp2px(Context context, float dpVal) {
    return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpVal, getDM(context));
}

From source file:Main.java

public static float getPixelsFromDp(Context context, int dp) {
    return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
            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()) + 0.5f;
}

From source file:Main.java

public static int getDimensionSize(int size) {
    return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, size,
            Resources.getSystem().getDisplayMetrics()));
}

From source file:Main.java

public static int dip2px(Context context, float dp) {
    return (int) (convertUnitToPixel(context, TypedValue.COMPLEX_UNIT_DIP, dp) + 0.5f);
}

From source file:Main.java

public 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 dpToPx(float dp, Context context) {
    return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
            context.getResources().getDisplayMetrics());
}