Skip to content

Instantly share code, notes, and snippets.

@DevPicon
Created January 26, 2018 19:16
Show Gist options
  • Save DevPicon/7db90855f6e3c49ff933557c9bb6df84 to your computer and use it in GitHub Desktop.
Save DevPicon/7db90855f6e3c49ff933557c9bb6df84 to your computer and use it in GitHub Desktop.
Some util methods to work with screen density and screenlayout
private boolean hasSmallDensity() {
int densityDpi = getResources().getDisplayMetrics().densityDpi;
if (densityDpi < DisplayMetrics.DENSITY_MEDIUM) {
return true;
}
return false;
}
private boolean hasSmallScreen() {
if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) {
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment