Android examples for User Interface:Screen Size
get Current Screen Width Inches
//package com.java2s; import android.content.Context; import android.util.DisplayMetrics; import android.view.Display; import android.view.WindowManager; public class Main { public static double getCurrentScreenWidthInches(Context context) { DisplayMetrics dm = getDisplayMetrics(context); return dm.widthPixels / dm.xdpi; }/* w w w . j a v a2 s . c o m*/ private static DisplayMetrics getDisplayMetrics(Context context) { DisplayMetrics dm = new DisplayMetrics(); getDefaultDisplay(context).getMetrics(dm); return dm; } private static Display getDefaultDisplay(Context context) { WindowManager wm = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); return wm.getDefaultDisplay(); } }