Updated onGlobalLayout() to check for API version.