Created
May 18, 2015 07:52
-
-
Save hoseinquest/9ac6bc9aef1db3f0f0d0 to your computer and use it in GitHub Desktop.
Andorid Detect Screen Size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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