Here you can find the source of convertDiptoPix(int dip, Context context)
public static int convertDiptoPix(int dip, Context context)
//package com.java2s; import android.content.Context; public class Main { public static int convertDiptoPix(int dip, Context context) { float scale = getDensity(context); return (int) (dip * scale + 0.5f); }/*from www .ja v a2 s . c o m*/ public static float getDensity(Context context) { float scale = context.getResources().getDisplayMetrics().density; return scale; } }