Skip to content

Instantly share code, notes, and snippets.

@tonylukasavage
Created July 19, 2012 20:20
Show Gist options
  • Save tonylukasavage/3146501 to your computer and use it in GitHub Desktop.
Save tonylukasavage/3146501 to your computer and use it in GitHub Desktop.
getSize() for Android in Titanium
@Kroll.getProperty @Kroll.method
public String getSize() {
switch(TiApplication.getInstance().getApplicationContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) {
case Configuration.SCREENLAYOUT_SIZE_SMALL :
return "small";
case Configuration.SCREENLAYOUT_SIZE_NORMAL :
return "normal";
case Configuration.SCREENLAYOUT_SIZE_LARGE :
return "large";
case 4 : // Configuration.SCREENLAYOUT_SIZE_XLARGE (API 9)
return "xlarge";
case Configuration.SCREENLAYOUT_SIZE_UNDEFINED:
default :
return "medium";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment