Java tutorial
//package com.java2s; import android.content.res.Resources; public class Main { /** * Converts dps to pixels * @param dps * @return pixels */ public static int toPx(Double dps) { final float scale = Resources.getSystem().getDisplayMetrics().density; return (int) (dps * scale + 0.5f); } }