Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;

import android.util.TypedValue;

public class Main {
    /**
     * dp to px
     * @param dip
     * @param context
     * @return
     */
    public static int dipTopx(float dip, Context context) {
        int num = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip,
                context.getResources().getDisplayMetrics());
        return num;
    }
}