Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.content.res.Resources;

import android.util.TypedValue;

public class Main {
    /**
     * Does conversion from dp to px.
     * @param resources
     * @param dp
     * @return float equivalent of pixels
     */
    public static float dpToPx(Resources resources, int dp) {
        return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics());
    }
}