Android examples for Phone:Screen
get Device Size
//package com.java2s; import android.content.Context; import android.util.Log; import android.view.WindowManager; public class Main { private static final String TAG = "DeviceUtil"; public static int getDeviceSize(Context context, int code) { WindowManager manager = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); int size; int width = manager.getDefaultDisplay().getWidth(); int height = manager.getDefaultDisplay().getHeight(); switch (code) { case 0://from www. j a v a2s .co m size = width; break; case 1: size = height; break; default: size = width; break; } Log.i(TAG, "Device size?Width:" + width + ",Height:" + height); return size; } }