I am trying to manually get an image inside an imageview centered and fitting the screen. I need to do it with a matrix (I will later dynamically change the matrix transform
There's a convenient method called Matrix.setRectToRect(RectF, RectF, ScaleToFit) to help you here.
Matrix m = imageView.getImageMatrix();
RectF drawableRect = new RectF(0, 0, imageWidth, imageHeight);
RectF viewRect = new RectF(0, 0, imageView.getWidth(), imageView.getHeight());
m.setRectToRect(drawableRect, viewRect, Matrix.ScaleToFit.CENTER);
imageView.setImageMatrix(m);
That should set the matrix m to have combo of scaling and translate values that is needed to show the drawable centered and fit within the ImageView widget.