Java tutorial
//package com.java2s; import android.content.Context; import android.util.TypedValue; public class Main { /** * Converts the gives DPs into pixels for rendering on the screen correctly */ protected static int convertDipsToPixels(Context context, float dps) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dps, context.getResources().getDisplayMetrics()); } }