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 getScreenMaxWidth(Context context, int paramInt) { Object localObject = new DisplayMetrics(); try { DisplayMetrics localDisplayMetrics = context.getApplicationContext().getResources().getDisplayMetrics(); localObject = localDisplayMetrics; return ((DisplayMetrics) localObject).widthPixels - dip2px(context, paramInt); } catch (Exception localException) { while (true) { localException.printStackTrace(); ((DisplayMetrics) localObject).widthPixels = 640; } } } public static int dip2px(Context context, float dpValue) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (dpValue * scale + 0.5f); } }