Canvas and Drawables Translation Episode 1
Android official original text address: http://developer.android.com/guide/topics/graphics/2d-graphics.html
------The following translation incorporates my own thinking, To facilitate understanding, the translation in many places is not very appropriate, so the original English text
Canvas and Drawables drawing board and drawings (the drawings are stretchable drawings)
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 framework APIs provide a series of 2D drawing APIs. These APIs allow you to render your own custom graphics (Graphics) to the artboard (Canvas), or modify existing views (Views) to customize them. Effect and experience. When drawing 2D graphics, there are generally two ways:
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.
Draw your graphics (Graphics) or animation into a View (View) object, through the layout file (layout). This way, the drawing of your graphics will be handled by the system's regular view-level drawing process -- you simply define the graphics into your view. This method probably refers to the background image defined in xml or the src attribute in ImageView.
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.
Draw your graphics (Graphics) directly to a drawing board (Canvas). In this method, you have to personally call the onDraw() method of the appropriate class (pass into your Canvas), or one of the Canvas draw...() methods (such as drawPicture()). By doing this, you can also control any animation.
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.
Option a, when you want to draw a simple graphic (Graphics), this graphics does not need to change dynamically or is not part of the performance-enhanced game. At this time, drawing the graphics into a view (View) is your best choice. For example: when you want to display a static graphic or a predefined animation, you should draw your graphic into a 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:
Option b, when your application needs to redraw itself on time, drawing into a canvas is a better choice. For example a video game application should be drawn to the artboard. Anyway, there are many ways to do it.
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.
In the same thread as your UI Activity, create a custom view component (View component) with your layout, call the invalidate() method, and then handle the onDraw() callback.
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()
). Or, in a separate thread, where you manage a SurfaceView and draw graphics to the Canvas as quickly as possible (you don't need to request Invalidate()
).
The above is the content of the first episode of Canvas and Drawables translation. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The edge browser comes with a translation function that allows users to translate anytime and anywhere, which brings great convenience to users. However, many users say that the built-in translation webpage is missing. Then the edge browser automatically What should I do if the translation page I brought is missing? Let this site introduce how to restore the translated web page that comes with the Edge browser if it is missing. How to restore the translation webpage that comes with the Edge browser is missing 1. Check whether the translation function is enabled: In the Edge browser, click the three dots icon in the upper right corner, and then select the "Settings" option. On the left side of the settings page, select the Language option. Make sure "Translate&rd"

According to news on July 22, today, the official Weibo of Xiaomi ThePaper OS announced that Xiaoai Translation has been upgraded. Real-time subtitles have been added to Japanese and Korean translations, and subtitle-free videos and live conferences can be transcribed and translated in real time. Face-to-face simultaneous interpretation supports translation into 12 languages, including Chinese, English, Japanese, Korean, Russian, Portuguese, Spanish, Italian, French, German, Indonesian, and Hindi. The above functions currently only support the following three new phones: Xiaomi MIX Fold 4 Xiaomi MIX Flip Redmi K70 Extreme Edition It is reported that in 2021, Xiao Ai’s AI subtitles will be added to Japanese and Korean translations. AI subtitles use Xiaomi’s self-developed simultaneous interpretation technology to provide a faster, more stable and accurate subtitle reading experience. 1. According to the official statement, Xiaoai Translator can not only be used in audio and video venues

How does Sogou browser translate? When we usually use Sogou browser to check information, we will encounter some websites that are all in English. Because we can’t understand English, it is very difficult to browse the website. This is also very inconvenient. It doesn’t matter if you encounter this situation! Sogou Browser has a built-in translation button. With just one click, Sogou Browser will automatically translate the entire webpage for you? If you don’t know how to operate it, the editor has compiled the specific steps on how to translate it on Sogou Browser. If you don’t know how, follow me and read on! How to translate Sogou Browser 1. Open Sogou Browser, click the translation icon in the upper right corner 2. Select the type of translation text, and then enter the text that needs to be translated 3. Sogou Browser will automatically translate the text. At this point, the above Sogou Browsing operation is completed. How to translate all contents

Browsers generally have built-in translation functions, so you don’t have to worry about not being able to understand when browsing foreign language websites! Google Chrome is no exception, but some users find that when they open the translation function of Google Chrome, there is no response or failure. What should they do? You can try the latest solution I found. Operation tutorial: Click the three dots in the upper right corner and click Settings. Click Add Language, add English and Chinese, and make the following settings for them. The English setting asks whether to translate web pages in this language. The Chinese setting displays web pages in this language, and Chinese must be moved to the top before it can be set as the default language. If you open the webpage and no translation option pops up, right-click and select Translate Chinese, OK.

Why can't Google Chrome translate Chinese? As we all know, Google Chrome is one of the browsers with built-in translation. When you browse pages written in other countries in this browser, the browser will automatically translate the page into Chinese. Recently, some users have said that they Chinese translation cannot be performed. At this time, we need to fix it in the settings. Next, the editor will bring you the solution to the problem that Google Chrome cannot translate into Chinese. Friends who are interested should come and take a look. Google Chrome cannot translate Chinese solutions 1. Modify the local hosts file. Hosts is a system file without an extension. It can be opened with tools such as Notepad. Its main function is to define the mapping relationship between IP addresses and host names. It is a mapping IP address

What should I do if Sogou Browser cannot translate this webpage? Sogou Browser is a very easy-to-use multi-functional browser. Its web page translation function is very powerful and can help us solve most of the troubles in study and work. However, some friends reported that Sogou Browser has a problem that it cannot translate this web page. This may be caused by improper operation. It can be solved by operating the translation function correctly. Below, the editor will bring you the problem that Sogou Browser cannot translate. Translate this page solution. Sogou Browser cannot translate this webpage Solution Method 1: 1. Download and install Sogou Browser 2. Open Sogou Browser 3. Open any English website 4. After the website is opened, click the translation icon in the upper right corner 5. Select Translate text type and click Translate current web page 6

Explore the Canvas framework: To understand what are the commonly used Canvas frameworks, specific code examples are required. Introduction: Canvas is a drawing API provided in HTML5, through which we can achieve rich graphics and animation effects. In order to improve the efficiency and convenience of drawing, many developers have developed different Canvas frameworks. This article will introduce some commonly used Canvas frameworks and provide specific code examples to help readers gain a deeper understanding of how to use these frameworks. 1. EaselJS framework Ea

In iOS 17.2, overcome communication barriers with new custom translation options for iPhone action buttons. Read on to learn how to use it. If you have an iPhone with an action button, like the iPhone 15 Pro, Apple's iOS 17.2 software update brings new translation options to the button, allowing you to translate live conversations into multiple languages. According to Apple, the translations are not only accurate, but also context-aware, ensuring nuances and spoken language are captured effectively. This feature should be a boon for travelers, students, and anyone learning a language. Before using the translation feature, be sure to select the language you want to translate into. You can do this through Apple's built-in Translate app
