Java tutorial
//package com.java2s; import android.content.res.Resources; import android.util.TypedValue; public class Main { /** * Converts the passed float value (dip) into pixels based on the resource * @param res the Resources to use for retrieving display metrics * @param value the dip value to convert * @return the passed dip's pixel equivalent. * * @deprecated use getResources().getDimensionPixelSize(R.dimen.your_dimension_to_convert); */ @Deprecated public static float convertFromDip(final Resources res, final float value) { return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, res.getDisplayMetrics()); } }