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