I need to disable a certain button in my app if the screen size of the Android device is considered SMALL (320dp x 426dp units). I am currently using:
if (activity.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {
//Is small size
} else {
//Is not small size
}
to determine the screen size of the device, however this never seems to enter the condition of Configuration.SCREENLAYOUT_SIZE_SMALL
. I did printouts and found that the value actually equates to Configuration.SCREENLAYOUT_SIZE_NORMAL
!
The answer from Alex Lockwood here: How do I get the ScreenSize programmatically in android is my reference for this solution, but as J R P noted on his answer, everything seemed to equate to Configuration.SCREENLAYOUT_SIZE_NORMAL
just like mine.
How do I reliably define the screen size of the device? I am currently testing on a Samsung Galaxy S3, and by all means this should have been a "small" device.
Thanks in advance, Rei