I want to determine whether the current device has a small, medium, large or xlarge screen in code. I can’t find anything in the SDK docs that would help me get to that information. All the methods / classes I have looked at provide only absolute values (i.e. screen size in pixels, screen density, etc.).
Is there a way to tell what kind of screen I’m running on in code?
I ended up using
boolresources placed in the different bucket folders. I only needed to differentiate between normal (small / medium) and large (large / xlarge) screens, so I did this:values/bools.xml
values-large/bools.xml
Then, I just call
getBoolean(R.bool.screen_large)to tell whether the screen is large or not. This way it’s 100% up to the platform decide what screen the device has.