Flip vertically an Android Canvas

2019-04-22 21:35发布

问题:

Is there an easy way to flip a canvas in Android? I cant seem to find anything that allows me to flip it vertically so that zero on the y-axis is the bottom of the phone screen instead of the top. It's OK if the solution isn't especially fast because I'm not doing anything computationally intense with the canvas.

Thanks in advance.

回答1:

Try

canvas.scale(1, -1, width / 2, height / 2)

See Canvas.scale documentation. The first two parameters are the amount to scale by.