Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.util.DisplayMetrics; public class Main { public static int getScreenMaxHeight(Context paramContext, int paramInt) { Object localObject = new DisplayMetrics(); try { DisplayMetrics localDisplayMetrics = paramContext.getApplicationContext().getResources() .getDisplayMetrics(); localObject = localDisplayMetrics; return ((DisplayMetrics) localObject).heightPixels - dip2px(paramContext, paramInt); } catch (Exception localException) { while (true) { localException.printStackTrace(); ((DisplayMetrics) localObject).heightPixels = 960; } } } public static int dip2px(Context context, float dpValue) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (dpValue * scale + 0.5f); } }