Skip to content

Instantly share code, notes, and snippets.

@granoeste
Created August 3, 2012 03:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save granoeste/3243965 to your computer and use it in GitHub Desktop.
Save granoeste/3243965 to your computer and use it in GitHub Desktop.
[Android] What Screen layout size?
// get screen layout long
int long = getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_LONG_MASK;
switch (long) {
case Configuration.SCREENLAYOUT_LONG_YES:
// Long screens, such as WQVGA, WVGA, FWVGA
break;
case Configuration.SCREENLAYOUT_LONG_NO:
// Not long screens, such as QVGA, HVGA, and VGA
break;
default:
break;
}
// @see http://developer.android.com/intl/ja/reference/android/content/res/Configuration.html#screenLayout
// get screen layout size
int size = getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK;
switch (size) {
case Configuration.SCREENLAYOUT_SIZE_XLARGE:
// 720x960 dp units
break;
case Configuration.SCREENLAYOUT_SIZE_LARGE:
// 480x640 dp units
break;
case Configuration.SCREENLAYOUT_SIZE_NORMAL:
// 320x470 dp units
break;
case Configuration.SCREENLAYOUT_SIZE_SMALL:
// 320x426 dp units
break;
default:
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment