Java tutorial
//package com.java2s; import android.content.Context; public class Main { public static int convertDpToPixel(Context context, float f) { // TODO Auto-generated method stub float density = context.getResources().getDisplayMetrics().density; return Math.round((float) f * density); } }