Java tutorial
//package com.java2s; import android.content.res.Resources; public class Main { /** * Convert DP to pixels using the device screen density */ public static int dpToPx(int dp) { float density = Resources.getSystem().getDisplayMetrics().density; return Math.round(dp * density); } }