Skip to content Skip to sidebar Skip to footer

Using An Imageview Transform Matrix Instead Of Canvas.scale(float, Float, Float, Float)

I need to change the way I am scaling and moving my imageview to using a matrix instead of calling canvas.scale(,,,,), but I cannot figure out the proper calls to do this. I had th

Solution 1:

Okay I figured out what the problem was. I was using setImageMatrix(m) to apply to the entire ImageView child class, instead of setting the matrix for the canvas, like this:

@OverrideprotectedvoidonDraw(Canvas canvas){

    ...
    canvas.concat(transform);

}

I'm not sure what the difference is between the two though, if anyone knows see difference bewteen imageMatrix and matrix

EDIT: using canvas.setMatrix(transform) messed up the scrolling; canvas.concat(transform) was recommended instead and that does this trick

Solution 2:

What if you try?

m.setScale(scaleFactor, scaleFactor);
m.postTranslate(zoomCenter[0], zoomCenter[1]);

I also believe child.setScaleType(ScaleType.MATRIX) is not needed. At least my coding works without it.

Post a Comment for "Using An Imageview Transform Matrix Instead Of Canvas.scale(float, Float, Float, Float)"