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

From source file:Main.java

public static int dpToPx(Resources res, int dp) {
    return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, res.getDisplayMetrics());
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static float dpToPx(Resources res, float dp) {
    float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, res.getDisplayMetrics());
    return px;//from w w  w.  j av a 2s .co m
}

From source file:Main.java

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

From source file:Main.java

private static int getDpToPx(int dp, Context context) {
    return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
            context.getResources().getDisplayMetrics());

}

From source file:Main.java

public static float convertDPtoPX(Context context, float dpVal) {
    return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpVal,
            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;/*w w  w . j ava  2s .  c om*/
}