Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.res.Resources;

import android.util.DisplayMetrics;

import android.util.TypedValue;

public class Main {
    public static int dpToPixels(int dp) {
        DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
        return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, displayMetrics));
        //return Math.round(dp * Resources.getSystem().getDisplayMetrics().density);
    }
}