Skip to content

Instantly share code, notes, and snippets.

@luftreich
Forked from granoeste/GetScreenLayoutLong.java
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luftreich/48905ff98ad7011e7505 to your computer and use it in GitHub Desktop.
Save luftreich/48905ff98ad7011e7505 to your computer and use it in GitHub Desktop.
// 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