Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; public class Main { /** * dp to px * * @param dp * @param context * @return */ public static int dpToPx(Context context, int dp) { return (int) (context.getResources().getDisplayMetrics().density * dp + 0.5f); } }