Android examples for User Interface:Screen Size
Method that get the Screen Size
//package com.java2s; import android.app.Activity; import android.graphics.Point; import android.view.Display; public class Main { /**/*from www .java2 s .c o m*/ * Method that get the Screen Size * @param activity Actual Activity * @return array type int */ public static int[] getScreenSize(Activity activity) { //Obtain default display Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); //Set Size in case of ICS if (android.os.Build.VERSION.SDK_INT >= 13) { display.getSize(size); return new int[] { size.x, size.y }; } else { return new int[] { display.getWidth(), display.getHeight() }; } } }