Here you can find the source of getPixelsFromDIP(Context context, int dipValue)
public static float getPixelsFromDIP(Context context, int dipValue)
//package com.java2s; import android.content.Context; import android.util.TypedValue; public class Main { public static float getPixelsFromDIP(Context context, int dipValue) { if (context != null) { return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, context.getResources().getDisplayMetrics()); }//from ww w . ja v a 2 s.co m return dipValue; } }