Java tutorial
//package com.java2s; import android.content.res.Resources; import android.util.TypedValue; public class Main { public static float getPxValue(int unit, float value) { return TypedValue.applyDimension(unit, value, Resources.getSystem().getDisplayMetrics()); } }