Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;
import android.util.TypedValue;

public class Main {
    /**
     * Converts density pixels to pixels
     *
     * @param context context for getResources()
     * @param dp      desired density pixels
     * @return converted dp to pixels
     */
    static float dpToPx(Context context, final int dp) {
        return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
                context.getResources().getDisplayMetrics());
    }
}