That doesn't really answer the question Generally, yes, Media Gallery 2.2 will always require the equivalent XenForo version, e.g. 2.2.
But when it comes to minor releases, the exact minimum versions may be slightly more diverged.
At this current moment, Media Gallery 2.2.2 requires XenForo 2.2.4.
As a general rule of thumb, if you're upgrading an official add-on and there is also a higher XenForo version, you should upgrade XenForo first, followed by the add-on. The latest XenForo version should work with any version of the add-on that's available.