Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; public class Main { static float dpToPx(Context context, int dp) { final float density = context.getResources().getDisplayMetrics().density; return density * dp / 160; } }