本文主要是介绍SurfaceView 使用步骤,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.继承SurfaceView2.实现SurfaceHolder.Callback接口
3.使用getHolder().addCallback(this);
4.重写surfaceChanged(...),surfaceCreated(..),surfaceDestroyed(..)
5.画图holder.lockCanvas()->画图ing->holder.unlockCanvasAndPost(..);
class MyView extends SurfaceView implements SurfaceHolder.Callback
{private SurfaceHolder holder;public MyView(Context context){super(context);holder = getHolder();holder.addCallback(this);}@Overridepublic void surfaceCreated(SurfaceHolder holder){...;}@Overridepublic void surfaceChanged(SurfaceHolder holder,int format,int width,int height){...;}@Overridepublic void surfaceDestroyed(SurfaceHolder holder){...;}}
这篇关于SurfaceView 使用步骤的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!