This example needs and procedures: The activity loads the custom Surfaceview-> Surfaceview constructor to start thread A, loops the x, y coordinates of the Surfaceview, and sets the fade flag bit picalphaflag to True when the x, Y coordinates go to a point- > surface is created as surfacecreated, thread B is started, and the loop draws the position of the graph in real time based on the Surfaceview x, y (changed by thread a), and fade another picture when Picalphaflag is true.
This example optimizes the point (personal Opinion): 1. Thread A and thread B can be merged;
This example revelation: 1. Surfaceview are usually used in custom; 2. Surfaceview typically have more than 1 sub-threads, performing time-consuming operations such as drawing, etc. 3. Surfaceview usually implements the Surfaceholder.callback interface, which is mainly used to manage the life cycle surfacecreated and surfacedestroyed; sample Demo
Custom Controls (2.2): Surfaceview and Surfaceholder