androidandroid-4.2-jelly-bean

What is the alternative for deprecated Canvas.getMatrix()?


I have the following code snippet, that transforms a set of bounds using the canvas' current transformation matrix.

    final RectF bounds = renderer.computeBounds
    activeCanvas.getMatrix().mapRect(result, bounds);
    return bounds;

However, with the latest API level (16) I get a warning stating

The method getMatrix() from the type Canvas is deprecated

as confirmed by the API 16 Diff Specification.

Which is fine and all, but the current documentation on Canvas.getMatrix() doesn't mention the deprecation, nor does it offer an alternative. As a workaround I now simply suppress this warning, but I would really like to know what the new and improved (tm) way of doing this looks like.


Solution

  • The Matrix is now handled by the view rather than the Canvas. I unfortunately can't explain you Google's decision on this one, but you should be able to reproduce the exact same things with the 2 ways.