Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.util.TypedValue; public class Main { /** * Converts density pixels into pixels. * * @param context the application context. * @param densityPixels the amount of DPs to convert. * @return the amount in pixels. */ public static int getPixels(Context context, int densityPixels) { return (int) Math.ceil(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, densityPixels, context.getResources().getDisplayMetrics())); } }