Java tutorial
//package com.java2s; //License from project: Apache License import android.app.Activity; import android.util.DisplayMetrics; public class Main { public static float dip2px2(Activity context, float dipValue) { DisplayMetrics dm = new DisplayMetrics(); context.getWindowManager().getDefaultDisplay().getMetrics(dm); final float screen = (float) dm.widthPixels / (float) 240; return screen; } }