Here you can find the source of getDensityDimen(Context context, int dimen)
public static int getDensityDimen(Context context, int dimen)
//package com.java2s; import android.content.Context; import android.util.DisplayMetrics; public class Main { public static int getDensityDimen(Context context, int dimen) { final DisplayMetrics dm = context.getResources() .getDisplayMetrics();//w w w.j a va 2 s . c o m return ((int) (dimen * dm.density)); } }