[Android] Chapter 2 2D graphics and animation, Chapter 2 of android

Source: Internet
Author: User

[Android] Chapter 2 2D graphics and animation, Chapter 2 of android

Category: C #, Android, VS2015;

Created on: 1. Introduction

The Android system defines a series of independent graphic processing classes. The 2D graphic processing classes are located in the following namespaces:

Android. Graphices

Android. Graphics. Drawable. Shapes

Android. View. Animation

The processing class of 3D images is located in the namespace of Android. Opengl.

In general, Android Graphics technology can be divided into two categories: Graphics and animation.

Graphics are further divided into 2D and 3D graphics.

2D graphics processing can be divided into two types: static graphics processing, used to process images that do not change frequently, such as comparison labels, logos, and animations, these images are generally added to the project as resource files (Resources/Drawable/, Resources/anim/); the other is dynamic graphics processing, images that will change frequently (size, position, and shape) are repeatedly copied and drawn on a regular basis, such as various scenes, tasks, and items in the game.

3D graphics are implemented through a large number of built-in frameworks (such as OpenGL ES for mobile versions) and other third-party frameworks (such as MonoGame, cross-platform tool kits compatible with XNA.

In this section, we mainly learn the basic 2D plotting and animation technologies built into Android.

1. Basic concepts of 2D Graphices

Android provides two APIs for creating 2D images.

First, it is used by declaring the canvas resource in the xml file. That is, you can use the drawing board resource to embed drawing instructions in an XML file or create custom images programmatically.

Second, it is a low-level API, which is generally used in a Canvas object. The most commonly used is drawing on the in-place graph and fine-grained control of the displayed content.

2. Basic animation concepts

In addition to 2D graphics technology, Android also provides several ways to create animations:

  • Drawable Animations-canvas animation. A simple animation API is provided for Frame-based playback. After a sequence is specified, Android will load and display the sequence of resources that can be drawn in sequence. The playback effect is similar to playing a cartoon (cartoon) cartoon.
  • View Animations-View animation. The original Android animation API is available in all versions of Android. This API is only applicable to simple conversions in View objects. These conversion files are generally defined in the/Resources/anim folder.
  • Property Animations-Property animation. This is an API introduced from Android 3.0, which allows animation (including View) of attributes of any object ). This flexibility allows animations to be encapsulated in different classes, making code sharing easier.

Note: View animation is only applicable to APIs provided by earlier Android 3.0 (API 11) versions. In other cases, attribute animation APIs should be used. In other words, although all three types of animations are available, attribute animations should be prioritized as long as possible. Ii. Main Interface of this Chapter

1. Run


2. Related code in the ch. cs File

chItems.Add (new Chapter ()
{
     ChapterName = "Chapter 21 2D Graphics and Animation",
     ChapterItems = new ChItem []
     {
         new ChItem {type = typeof (ch2101MainActivity), Title = "Example 21-1 Basic syntax of drawing board", Desc = "Demonstrate the basic usage of Drawable Resource"},
         new ChItem {type = typeof (ch2102MainActivity), Title = "Example 21-2 Canvas Basic Syntax", Desc = "Demonstrate Canvas Basic Usage"},
         new ChItem {type = typeof (ch2103MainActivity), Title = "Example 21-3 basic syntax of animation", Desc = "Demonstrate basic usage of animation"},
     }
}); 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.