Android官方原文網址:http://developer.android.com/guide/topics/graphics/2d-graphics.html
------以下的翻譯融入了自己的思考,便於理解,很多地方翻譯不是很恰當,所以配上了英文原文
Canvas and Drawables 畫板和圖紙(圖紙是可拉伸的圖紙)
IN THIS DOCUMENT
Draw with a Canvas
On a View Drawables
Creating from resource
images
Creating from resource
XML
Shape Drawable
Nine-patch
SEE ALSO
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,
Android'll typically do so in one of of two API: 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 hiermarchy soo 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()
選項a,當你想繪製一個簡單的圖形(圖形或不是效能加強的遊戲的一部分,這個時候,吧圖形繪製到一個視圖(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 should be drawing to the Canvas on its own. However, thereones more thanever dole do. :
In the same thread as your UI Activity, wherein you create a custom View component in your layout, call
draw...()
invalidate()
以上就是Canvas and Drawables 翻譯第一集的內容,更多相關內容請關注PHP中文網(www.php.cn)!