Android Custom Surfaceview Detailed _android

Source: Internet
Author: User

This article briefly discusses the architecture of future Android game engine templates. In the Android game development Tutorial II: The View class and the Surfaceview class we've talked about, Surfaceview class has a lot of advantages, so in the Android game development or choose Surfaceview.

Here we inherit Surfaceview directly, implement Surfaceholder.callback interface, deal with surfacecreated, surfacechanged and Surfacedestroyed methods, Here we do not have the key to control the incoming, the final game control aspects of the view is still the internal class processing is better, For specific Surfaceview, we can see the control implementation of camera in the Android Open source project on screen capture and videoview you can clearly understand the ultimate intention.

Java code

public class Cwjview extends Surfaceview implements Surfaceholder.callback {public  
  
  
 Cwjview AttributeSet attrs) {  
 Super (context, attrs);  
 Surfaceholder Holder=getholder ();  
 Holder.addcallback (this);   
   
 Setfocusable (true);  
  
 public void surfacechanged (surfaceholder holder, int format, int width, int height) {  
   
   
 } public  
 
 void surfacecreated (Surfaceholder Holder) {  
   
   
 } public  
 
 void Surfacedestroyed (Surfaceholder holder) {  
   
 
   
 }  
  
 @Override public 
 Void Onwindowfocuschanged (Boolean haswindowfocus) {  
   
 }  
    

The above is to the Android Surfaceview data collation, follow-up continue to supplement the relevant information, thank you for your support of this site!

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.