Java tutorial
//package com.java2s; //License from project: Apache License import android.content.res.Resources; public class Main { public static float getPixelsFromDp(int dp) { return dp * Resources.getSystem().getDisplayMetrics().density; } }