I was given a task to provide devices with < 1024×800 resolution with one group of layouts and >=1024×800 – with another.
Below there’s some code I’m using. Regarding on _isTablet flag application can decide which layout it should use.
Do you think it’s a decent tactic or should I consider another functionality for achieving resolution-based segregation of design layouts ? Thanks.
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
final int height = display.getHeight();
final int width = display.getWidth();
_leadingSideResolution = Math.max(height, width);
if (_leadingSideResolution <= HANDSET_LAYOUT_RESOLUTION) {
_isTablet = false;
} else if(_leadingSideResolution > HANDSET_LAYOUT_RESOLUTION
&& _leadingSideResolution <= TABLET_LAYOUT_RESOLUTION) {
_isTablet = true;
}
Try this code to check whether the device is tablet or not