Android Canvas Flip is a tool, especially in image processing, without the need to transpose the array of arrays to reverse a bunch of linear changes can easily achieve the origin of the change.
Like Jiangzi, at the beginning, the canvas sister is and display area elder brother overlap together, tacit understanding like a person, three views consistent, starting point unification in the upper left corner. The images we draw are all on the canvas and are rendered in the display area. Drawing a progress bar on the canvas at this point is the effect.
If you want to get a vertical bar, then we will flip the canvas, first counter-clockwise 90 °, get
Then the canvas sister and display area Brother's world is not the same coordinate system
Their world is divided, in order to make them see the world is the same world, canvas sister also relative to its coordinates origin negative to move a display area of the getheight, complete.
The canvas of the control is converted, and we get a vertical control. The code is implemented as:
protectedsynchronizedvoidonDraw(Canvas canvas) { canvas.rotate(-90); canvas.translate(-getHeight(),0); super.onDraw(canvas); }
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
<Android> Moving and flipping the canvas