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 翻译第一集的内容,更多相关内容请关注PHP中文网(www.php.cn)!

H5不仅仅是HTML5的简称,它代表了一个更广泛的现代网页开发技术生态:1.H5包括HTML5、CSS3、JavaScript及相关API和技术;2.它提供更丰富、互动、流畅的用户体验,能在多设备上无缝运行;3.使用H5技术栈可以创建响应式网页和复杂交互功能。

H5与HTML5指的是同一个东西,即HTML5。HTML5是HTML的第五个版本,带来了语义化标签、多媒体支持、画布与图形、离线存储与本地存储等新功能,提升了网页的表现力和交互性。

H5referstoHTML5,apivotaltechnologyinwebdevelopment.1)HTML5introducesnewelementsandAPIsforrich,dynamicwebapplications.2)Itsupportsmultimediawithoutplugins,enhancinguserexperienceacrossdevices.3)SemanticelementsimprovecontentstructureandSEO.4)H5'srespo

H5开发需要掌握的工具和框架包括Vue.js、React和Webpack。1.Vue.js适用于构建用户界面,支持组件化开发。2.React通过虚拟DOM优化页面渲染,适合复杂应用。3.Webpack用于模块打包,优化资源加载。

HTML5hassignificantlytransformedwebdevelopmentbyintroducingsemanticelements,enhancingmultimediasupport,andimprovingperformance.1)ItmadewebsitesmoreaccessibleandSEO-friendlywithsemanticelementslike,,and.2)HTML5introducednativeandtags,eliminatingthenee

H5通过语义化元素和ARIA属性提升网页的可访问性和SEO效果。1.使用、、等元素组织内容结构,提高SEO。2.ARIA属性如aria-label增强可访问性,辅助技术用户可顺利使用网页。

"h5"和"HTML5"在大多数情况下是相同的,但它们在某些特定场景下可能有不同的含义。1."HTML5"是W3C定义的标准,包含新标签和API。2."h5"通常是HTML5的简称,但在移动开发中可能指基于HTML5的框架。理解这些区别有助于在项目中准确使用这些术语。

H5,即HTML5,是HTML的第五个版本,它为开发者提供了更强大的工具集,使得创建复杂的网页应用变得更加简单。H5的核心功能包括:1)元素允许在网页上绘制图形和动画;2)语义化标签如、等,使网页结构清晰,利于SEO优化;3)新API如GeolocationAPI,支持基于位置的服务;4)跨浏览器兼容性需要通过兼容性测试和Polyfill库来确保。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境

SublimeText3 Linux新版
SublimeText3 Linux最新版

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

Dreamweaver CS6
视觉化网页开发工具