How can I get the screen width and height and use this value in:
@Override protected void onMeasure(int widthSpecId, int heightSpecId) {
Log.e(TAG, \"onM
int getScreenSize() {
int screenSize = getResources().getConfiguration().screenLayout &
Configuration.SCREENLAYOUT_SIZE_MASK;
// String toastMsg = "Screen size is neither large, normal or small";
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
int orientation = display.getRotation();
int i = 0;
switch (screenSize) {
case Configuration.SCREENLAYOUT_SIZE_NORMAL:
i = 1;
// toastMsg = "Normal screen";
break;
case Configuration.SCREENLAYOUT_SIZE_SMALL:
i = 1;
// toastMsg = "Normal screen";
break;
case Configuration.SCREENLAYOUT_SIZE_LARGE:
// toastMsg = "Large screen";
if (orientation == Surface.ROTATION_90
|| orientation == Surface.ROTATION_270) {
// TODO: add logic for landscape mode here
i = 2;
} else {
i = 1;
}
break;
case Configuration.SCREENLAYOUT_SIZE_XLARGE:
if (orientation == Surface.ROTATION_90
|| orientation == Surface.ROTATION_270) {
// TODO: add logic for landscape mode here
i = 4;
} else {
i = 3;
}
break;
}
// customeToast(toastMsg);
return i;
}