Java tutorial
//package com.java2s; //License from project: Apache License import android.util.DisplayMetrics; import android.util.TypedValue; public class Main { static int dp(float dp, DisplayMetrics metrics) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, metrics); } }