• 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

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

Canvas and Drawables 画板和图纸(图纸是可拉伸的图纸)

IN THIS DOCUMENT

Draw with a Canvas

On a View
On a SurfaceView

Drawables

Creating from resource
images
Creating from resource
XML

Shape Drawable
Nine-patch

SEE ALSO

OpenGL with the Framework APIs
RenderScript

The Android framework APIs provides a set of 2D-drawing APIs that allow you to render your own custom graphics onto a canvas or to modify existing Views to customize their look and feel. When drawing 2D graphics,
you'll typically do so in one of two ways:
Android框架APIs提供了一系列的2D绘制APIs,这些APIs允许你渲染你自己的自定义图形(Graphics)到画板(Canvas)上,或者修改已经存在的视图(Views)来定制它们的效果和体验。当绘制2D图形的时候,一般有两种方式:

Draw your graphics or animations into a View object from your layout. In this manner, the drawing of your graphics is handled by the system's normal View hierarchy drawing process — you simply define the graphics to go inside
the View.
绘制你的图形(Graphics)或动画到一个视图(View)对象里面,通过布局文件(layout)。用这种方式,你的图形的绘制 将要被系统的正规的 视图层级绘制进程处理---你只要简单的定义图形到你的视图(View)里面。这种方式估计是说xml中定义的背景图片或ImageView里的src属性。
Draw your graphics directly to a Canvas. This way, you personally call the appropriate class's

onDraw()

method
(passing it your Canvas), or one of the Canvas

draw...()

).In doing so, you are also in control of any animation.
直接绘制你的图形(Graphics)到一个画板(Canvas),这种方法,你要亲自调用适当类的onDraw()方法(传入你的Canvas),或者Canvas draw...()方法之一(比如drawPicture())。这样做,你也能够把控任何动画。

Option "a," drawing to a View, is your best choice when you want to draw simple graphics that do not need to change dynamically and are not part of a performance-intensive game. For example, you should draw your
graphics into a View when you want to display a static graphic or predefined animation, within an otherwise static application. Read Drawables for
more information.
选项a,当你想绘制一个简单的图形(Graphics),这个图形不需要动态改变或不是性能加强的游戏的一部分,这个时候,吧图形绘制到一个视图(View)里,是你最好的选择。例如:当你想显示一张静态的图形或预先定义好的动画,你应当将你的图形绘制到一个视图(View)里。
Option "b," drawing to a Canvas, is better when your application needs to regularly re-draw itself. Applications such as video games should be drawing to the Canvas on its own. However, there's more than one way
to do this:
选项b,当你的应用需要按时地重绘自己的时候,绘制到一个画板(Canvas)里是一个更好的选择。例如视频游戏应用应该绘制到画板上。不管怎么说,有很多方法可以做这件事。

In the same thread as your UI Activity, wherein you create a custom View component in your layout, call

invalidate()

and
then handle the

onDraw()

callback.
在和你UI Activity 的同一个线程里,在其中用你的layout创建一个自定义视图组件(View component),调用invalidate()方法,然后处理onDraw()回调。
Or, in a separate thread, wherein you manage a

SurfaceView

and
perform draws to the Canvas as fast as your thread is capable (you do not need to request

invalidate()

).或者,在一个独立分开的线程里,在其中你管理一个SurfaceView和尽可能快的将图形绘制到画板(Canvas)上(你不需要请求Invalidate()

)。

以上就是Canvas and Drawables 翻译第一集的内容,更多相关内容请关注微课江湖()!

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

  • 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-03html特殊符号示例 html特殊字符编码对照表_html5教程技巧
  • 2018-12-03App Store 或者 Google Play Store 中有哪些不错的 HTML5 app?
  • 2017-08-06HTML5中Localstorage的使用教程
  • 2018-12-03phonegap进行提示操作的具体示例代码分享
  • 2018-12-03html5摇一摇代码优化包括DeviceMotionEvent等等_html5教程技巧
  • 2018-12-03介绍HTML5+Canvas调用手机拍照功能实现图片上传(上篇)
  • 2018-12-03HTML5 Canvas 破碎重组的视频特效代码具体介绍
  • 2018-12-03html5几种在客户端存储数据的实例详解
  • 2018-12-03炫酷实用的jQuery/HTML5菜单图文详解
  • 2018-12-03html5 学习简单的拾色器 _html5教程技巧

文章分类

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

最近更新的内容

    • HTML5如何为形状图上颜色怎么绘制具有颜色和透明度的矩形_html5教程技巧
    • 有关基础模板的课程推荐
    • Html5移动端获奖无缝滚动动画实现
    • 使用HTML5在网页中嵌入音频和视频播放的基本方法_html5教程技巧
    • 有关跨域通信的文章推荐10篇
    • HTML5-表单输入验证详解(图文)
    • 微信浏览器取消缓存的方法
    • 移动端HTML5音频与视频遇到的问题及解决方案
    • html5如何实现图片转圈的动画效果
    • 微信公众号html5专题页面用什么软件制作?又如何发布到公众号上?

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

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