Android examples for User Interface:Window
get Screen Config
//package com.java2s; import android.content.Context; import android.view.WindowManager; import java.lang.reflect.Field; public class Main { public static int screenWidth = 0; public static int screenHeight = 0; public static int statusBar = 0; public static void getScreenConfig(Context context) { WindowManager wm = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); int width = wm.getDefaultDisplay().getWidth(); int height = wm.getDefaultDisplay().getHeight(); Class<?> c = null;// w w w . ja va 2 s. c om Object obj = null; Field field = null; int x = 0, sbar = 0; try { c = Class.forName("com.android.internal.R$dimen"); obj = c.newInstance(); field = c.getField("status_bar_height"); x = Integer.parseInt(field.get(obj).toString()); sbar = context.getResources().getDimensionPixelSize(x); } catch (Exception e1) { e1.printStackTrace(); } screenWidth = width; screenHeight = height - sbar; statusBar = sbar; } }