android surfaceView与view使用小结
2012-04-14 17:33
274 查看
两种方法都是实现画一个慢慢变大的圆, 自定义的view要sleep一下才能看到效果 . surfaceView不用. 可能与其两级缓存有关.
_____________________________________最美分割线_________________________________________
使用它主要就是
SurfaceHolder sh = this.getHolder();--->1.得到SurfaceHolder
Canvas canvas = sh.lockCanvas();---->2. 锁定画布
Paint paint = new Paint();
paint.setColor(Color.RED); ----->3. 在画布上干事
canvas.drawCircle(100, 100, radius, paint);
sh.unlockCanvasAndPost(canvas); ----->4. 解除锁定
下面图片为全部代码.
_____________________________________最美分割线__________________________________________
view主要干活的是onDraw()方法.这个不用手动调(不像surfaceview还得还一个surfaceHolder.addCallback()方法)
其实surfaceview里的surfaceHolder.addCallback()方法是不断的调用Draw()方法. 这个方法文档的解释: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, implement
_____________________________________最美分割线_________________________________________
使用它主要就是
SurfaceHolder sh = this.getHolder();--->1.得到SurfaceHolder
Canvas canvas = sh.lockCanvas();---->2. 锁定画布
Paint paint = new Paint();
paint.setColor(Color.RED); ----->3. 在画布上干事
canvas.drawCircle(100, 100, radius, paint);
sh.unlockCanvasAndPost(canvas); ----->4. 解除锁定
下面图片为全部代码.
_____________________________________最美分割线__________________________________________
view主要干活的是onDraw()方法.这个不用手动调(不像surfaceview还得还一个surfaceHolder.addCallback()方法)
其实surfaceview里的surfaceHolder.addCallback()方法是不断的调用Draw()方法. 这个方法文档的解释: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, implement
onDraw(android.graphics.Canvas)instead of overriding this method. If you do need to override this method, call the superclass version.
相关文章推荐
- android surfaceView 的简单使用 画图,拖动效果
- Android UI SurfaceView的使用-绘制组合图型,并使其移动
- android SurfaceView初次使用错误解决办法 (二)
- Android游戏开发之SurfaceView的使用-android学习之旅(五)
- Android学习之 WebView使用小结
- Android之SurfaceView使用总结
- Android提高第二篇之SurfaceView的基本使用
- Android之MediaPlayer——SurfaceView的简单使用
- android:使用SurfaceView游戏开发简单屏幕适配方法
- Android UI SurfaceView的使用-绘制单个图型或多个图形
- Android UI SurfaceView的使用-绘制单个图型或多个图形
- Android之SurfaceView使用总结
- android中使用surfaceview+MediaPlayer播放视频
- Android-BottomNavigationView使用小结
- Android之surfaceView使用总结
- Android解决Fragment中使用SurfaceView切换时闪一下黑屏的问题
- Android的SurfaceView使用
- android 使用双缓冲辨析及surfaceview使用例程
- Android UI SurfaceView的使用-绘制组合图型,并使其移动
- Android之SurfaceView使用总结