Java tutorial
//package com.java2s; import android.content.Context; public class Main { /** * dp ---> px */ public static int dp2px(Context context, float dpValue) { final float scale = context.getApplicationContext().getResources().getDisplayMetrics().density; return (int) (dpValue * scale + 0.5f); } }