• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com专业计算机教程网站
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure
您的位置:首页 > 网页设计 >html5 > Canvas and Drawables 翻译第三集

Canvas and Drawables 翻译第三集

作者:匿名 字体:[增加 减小] 来源:互联网 时间:2018-12-03

本文主要包含Canvas,Drawables, 翻译等相关知识,匿名希望在学习及工作中可以帮助到您


Android官方原文地址:http://developer.android.com/guide/topics/graphics/2d-graphics.html

------以下的翻译融入了自己的思考,便于理解,很多地方翻译并不是很恰当,所以配上了英文原文

[title3]
On a View 在视图组件上(View)上[/title3]

If your application does not require a significant amount of processing or frame-rate speed (perhaps for a chess game, a snake game, or another slowly-animated application), then you should consider creating a custom View component and drawing with a Canvas
in

View.onDraw()

.
The most convenient aspect of doing so is that the Android framework will provide you with a pre-defined Canvas to which you will place your drawing calls.

如果你的应用不需要大量的处理或没有帧速率要求,像棋牌类游戏、贪吃蛇、或者慢动画应用,你可以考虑创建一个自定义视图组件(View)并且使用画板(Canvas)在View.onDraw()方法里绘制。这样做最大的方便之处在于Android框架层将为你提供一个预先定义好的画板(Canvas),你可以使用该Canvas进行绘制。

To start, extend the

View

class (or descendant
thereof) and define the

onDraw()

callback
method. This method will be called by the Android framework to request that your View draw itself. This is where you will perform all your calls to draw through the

Canvas

,
which is passed to you through the

onDraw()

callback.

首先,继承View类(或者子类),并且定义onDraw()回调方法。该方法将会被Android框架层调用,使得你的View绘制自己。在这个地方将要执行你需要的所有绘制调用,并且Canvas会通过onDraw()回调方法传入。

The Android framework will only call

onDraw()

as necessary. Each time that your application is prepared to be drawn, you must request your View be invalidated by calling

invalidate()

.
This indicates that you'd like your View to be drawn and Android will then call your

onDraw()

method (though is not guaranteed that the callback will be instantaneous).

Android框架层只会在需要的时候调用onDraw()方法。每次当你的应用准备好需要去绘制的时候,你必须通过invalidate()方法使你的View无效。这表示你想要你的View被绘制并且Android将要回调你的onDraw()方法(不保证这个回调将会被及时执行)

Inside your View component's

onDraw()

, use the Canvas given to you for all your drawing, using various

Canvas.draw...()

methods,
or other class

draw()

methods that take your Canvas as an argument. Once your

onDraw()

is complete, the Android
framework will use your Canvas to draw a Bitmap handled by the system.

在你的View组件里的onDraw()方法中,使用给你的Canvas作你所有的绘制,使用各种各样的Canvas.draw...()方法,或者其他类的Draw()方法,这个类能够把给你的Canvas作为参数传入。一旦你的onDraw()方法完成,Android框架将要用你的Canvas去绘制一张位图。

Note: In order to request an invalidate from a thread other than your main Activity's thread, you must call

postInvalidate()

您可能想查找下面的文章:

  • canvas与html5实现视频截图功能示例
  • 详解html5 canvas常用api总结(二)--绘图API
  • HTML5 Canvas玩转酷炫大波浪进度图效果实例(附demo)
  • 详解使用HTML5 Canvas创建动态粒子网格动画
  • 解决canvas转base64/jpeg时透明区域变成黑色背景的方法
  • 用html5的canvas和JavaScript创建一个绘图程序的简单实例
  • HTML5 canvas基本绘图之图形组合
  • HTML5 canvas基本绘图之文字渲染
  • HTML5 canvas基本绘图之绘制曲线
  • HTML5 canvas基本绘图之图形变换

相关文章

  • 2018-12-03vue实现图片滚动效果
  • 2018-12-03推荐WEB开发者最佳HTML5和CSS3代码生成器_html5教程技巧
  • 2018-12-03HTML5多媒体audio和video详细介绍(二)
  • 2018-12-03input实现文字超出省略号(代码示例)
  • 2018-12-03用exfe.js和canvas解决移动端 IOS 拍照上传图片翻转问题(附代码)
  • 2018-12-03html5拍照功能实现代码(htm5上传文件)_html5教程技巧
  • 2017-09-04HTML5中的video&audio
  • 2018-12-03html5+css3实现一款注册表单实例_html5教程技巧
  • 2017-08-06Html5新标签datalist实现输入框与后台数据库数据的动态匹配
  • 2018-12-03HTML5 拖放功能实现代码

文章分类

  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure

最近更新的内容

    • 纯HTML5+CSS3制作生日蛋糕代码
    • html5+css3实现一款注册表单实例
    • HTML5学习笔记简明版(10):废弃的元素和属性
    • HTML5与Flash对比
    • HTML5 语音搜索(淘宝店语音搜素)_html5教程技巧
    • 20佳惊艳的HTML5应用程序示例分享_html5教程技巧
    • html5 常用标签汇总详情
    • 如果全世界电脑停用flash转用HTML5,可以节省多少能源?
    • AngularJS“路由”的简介及用法介绍
    • HTML5之SVG 2D入门10—滤镜的定义及使用

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有