Here you can find the source of dip2px(Context context, float dpValue)
public static int dip2px(Context context, float dpValue)
//package com.java2s; //License from project: Apache License 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 w w w . jav a2 s . c om*/ }