Skip to content

Instantly share code, notes, and snippets.

@hoseinquest
Created May 18, 2015 07:52
Show Gist options
  • Save hoseinquest/9ac6bc9aef1db3f0f0d0 to your computer and use it in GitHub Desktop.
Save hoseinquest/9ac6bc9aef1db3f0f0d0 to your computer and use it in GitHub Desktop.
Andorid Detect Screen Size
int screenSize = getResources().getConfiguration().screenLayout &
Configuration.SCREENLAYOUT_SIZE_MASK;
switch(screenSize) {
case Configuration.SCREENLAYOUT_SIZE_LARGE:
Toast.makeText(this, "Large screen",Toast.LENGTH_LONG).show();
break;
case Configuration.SCREENLAYOUT_SIZE_NORMAL:
Toast.makeText(this, "Normal screen",Toast.LENGTH_LONG).show();
break;
case Configuration.SCREENLAYOUT_SIZE_SMALL:
Toast.makeText(this, "Small screen",Toast.LENGTH_LONG).show();
break;
default:
Toast.makeText(this, "Screen size is neither large, normal or small" , Toast.LENGTH_LONG).show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment