<Android> Moving and flipping the canvas

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.