code: private void fixScaleTrans() {
          fixTrans();
          matrix.getValues(m);
          if (getImageWidth() < viewWidth) {
              m[Matrix.MTRANS_X] = (viewWidth - getImageWidth()) / 2;
          }
  
          if (getImageHeight() < viewHeight) {
              m[Matrix.MTRANS_Y] = (viewHeight - getImageHeight()) / 2;
          }
          matrix.setValues(m);
      }
docs: When transitioning from zooming from focus to zoom from center (or vice versa)
  the image can become unaligned within the view. This is apparent when zooming
  quickly. When the content size is less than the view size, the content will often
  be centered incorrectly within the view. fixScaleTrans first calls fixTrans() and
  then makes sure the image is centered correctly within the view.