Android examples for Phone:Screen
get Device Size Resources
//package com.java2s; import android.content.Context; import android.content.res.Resources; import android.util.DisplayMetrics; import android.util.Log; public class Main { private static final String TAG = "DeviceUtil"; public static int getDeviceSize_Resources(Context context, int code) { Resources resources = context.getResources(); DisplayMetrics outMetrics = resources.getDisplayMetrics(); int size; float density = outMetrics.density; int width = outMetrics.widthPixels; int height = outMetrics.heightPixels; switch (code) { case 0:/*from w w w. j av a 2s . c o m*/ size = width; break; case 1: size = height; break; default: size = width; break; } Log.i(TAG, "Device size?Width:" + width + ",Height:" + height + ",Density:" + density); return size; } }