Summary of use of android surfaceView and view

Source: Internet
Author: User

The two methods are to draw a circle that gradually increases, and the custom view needs to sleep to see the effect. surfaceView is not needed. It may be related to its two-level cache.
_____________________________________ Most beautiful split line _________________________________________
It is mainly used
SurfaceHolder sh = this. getHolder (); ---> 1. Obtain SurfaceHolder.
Canvas canvas = sh. lockCanvas (); ----> 2. Lock the Canvas
Paint paint = new Paint ();
Paint. setColor (Color. RED); -----> 3. Officer on the canvas
Canvas. drawCircle (100,100, radius, paint );
Sh. unlockCanvasAndPost (canvas); -----> 4. Unlock

The following figure shows all the codes.

_____________________________________ Most beautiful split line __________________________________________

View mainly works on the onDraw () method. You do not need to manually call this method (unlike surfaceview, you have to return a surfaceHolder. addCallback () method)

SurfaceHolder in surfaceview. the addCallback () method constantly calls the Draw () method. description of this method document: Manually render this view (and all of its children) to the given Canvas. the view must have already done a full layout before this function is called. when implementing a view, implementonDraw(android.graphics.Canvas)Instead of overriding this method. If you do need to override this method, call the superclass version.

Related Article

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.