Here you can find the source of dip2px(Context context, float dpValue)
public static int dip2px(Context context, float dpValue)
//package com.java2s; import android.content.Context; import android.util.Log; public class Main { public static int dip2px(Context context, float dpValue) { final float scale = context.getResources().getDisplayMetrics().density; Log.e("desitiny", scale + ""); return (int) (dpValue * scale / 1.5 + 0.5f); }//from www . j av a 2 s .c o m }