Android drawing study summary (4) - Animation (on)

2010-06-21  来源:本站原创  分类:Mobile  人气:231 

With a deep understanding of the Drewable discovered Drawable more powerful features: Display Animation. Android SDK introduces two kinds of Animation:

* Tween Animation: By constantly doing the scene where the object image transformation (translation, scaling, rotation) generated animation
* Frame Animation: play in order to make proper image, with a similar film

The use of Animation, we first learn how to define Animation, which we will be very helpful to use Animation. Animation is defined in XML format, defined XML files stored in the res \ anim in. As the Tween Animation Frame Animation with the definition, use the big difference, we will separate the description, the space described in the definition and use of Tween Animation, further details of the follow-up length Frame Animation. In accordance with the structure of XML documents 【parent node, child nodes, attributes】 to introduce Tween Animation, its the 4 types:

* Alpha: gradient transparency animation
* Scale: Gradient size expansion animation
* Translate: animation moving picture conversion position
* Rotate: scene change position moving animation

Introducing the 4 types above before introducing Tween Animation common node attributes, node name on the principles, please read the instructions AndroidManifest.xml file structure.

Table 1 attribute [type] function
Duration [long] attribute for the animation duration time in milliseconds
fillAfter [boolean] When set to true, the animation after the end of conversion applications in animation
fillBefore [boolean] When set to true, the animation transformation is applied before in animation

interpolator
Specify an animation of inserting the insertion device has a number of common devices
accelerate_decelerate_interpolator
Acceleration - deceleration animation Inserter
accelerate_interpolator
Acceleration - Animation Inserter
decelerate_interpolator
Deceleration - the other device is inserted animation animation-specific
repeatCount [int] animation repetition
RepeatMode [int] the definition of repetitive behavior 1: start 2: plays backward
startOffset [long] time between animation, animation stop from the time the last started for the next animation
zAdjustment [int] the definition of animation changes in Z Order 0: Z Order remain unchanged
1: Keep on top
-1: Keep in the most lower

Read more nodes, we are not want to start the definition of animation. Here we begin with concrete examples to introduce the 4 types of elements specific to each node.

Table 2
XML Node Function
gradient alpha transparency animation
<Alpha
android: fromAlpha = "0.1"
android: toAlpha = "1.0"
android: duration = "3000" />
fromAlpha

Time to onset of transparency in property animation
0.0 that fully transparent
1.0 that the value of taking over completely opaque float between 0.0-1.0 types of digital data
toAlpha property at the end of transparency animation

Table 3
size scale gradient expansion animation
<Scale
android: interpolator = "@ android: anim / accelerate_decelerate_interpolator"
android: fromXScale = "0.0"
android: toXScale = "1.4"
android: fromYScale = "0.0"
android: toYScale = "1.4"
android: pivotX = "50%"
android: pivotY = "50%"
android: fillAfter = "false"
android: startOffset = "700"
android: duration = "7000"
android: repeatCount = "1"
/>
fromXScale [float] fromYScale [float] for the animation start time, X, Y coordinates of the expansion size of 0.0 that did not shrink to
1.0 that the normal value of less than 1.0, said non-flexible contract value is greater than 1.0, said to enlarge
toXScale [float]
toYScale [float] end of the animation, X, Y coordinates of the expansion size
pivotX [float]
pivotY [float] for the animation relative to the objects X, Y coordinates of the beginning of the description attribute value: from 0% -100% in value, 50% of X or Y direction of the object coordinates of the midpoints

Table 4
location of moving picture converting translate animation
<Translate
android: fromXDelta = "0"
android: toXDelta = "-80"
android: fromYDelta = "-60"
android: toYDelta = "300"
android: duration = "2000"
/>
fromXDelta
toXDelta for the animation, when the end X coordinates start position
fromYDelta
toYDelta for the animation, the end of the starting position when the Y coordinates

Table 5
rotate the screen rotation animation transfer
<Rotate
android: interpolator = "@ android: anim / accelerate_decelerate_interpolator"
android: fromDegrees = "0"
android: toDegrees = "+350"
android: pivotX = "50%"
android: pivotY = "50%"
android: duration = "3000" />
fromDegrees for the animation start point when the object description when the angle is negative - that counterclockwise rotation when the angle is positive - that clockwise rotation
(Negative from - to a positive number: clockwise rotation)
(Negative from - to negative: anti-clockwise rotation)
(Positive from - to a positive number: clockwise rotation)
(Positive from - to negative: anti-clockwise rotation)
toDegrees property objects for animation at the end of the angle of rotation can be greater than 360 degrees
pivotX
pivotY for the animation relative to the objects X, Y coordinates of the start bit Note: these two property values from 0% -100% in value
50% of X or Y direction of the object coordinates of the midpoints

Read the example above, presumably you also want to see, these definitions of animation, and running is what effect, following the example of the animation is running Scale, the interface changes as follows:

Android drawing study summary (4) - Animation (on)
Android drawing study summary (4) - Animation (on)

Android drawing study summary (4) - Animation (on)
Android drawing study summary (4) - Animation (on)

Finished in accordance with the above described learning the definition of Tween Animation on Tween Animation with a detailed understanding of go under the Android SDK to understand the animation package (android.view.animation), provided the operation of all classes Tween Animation.

Android SDK provides the base class: Animation, contains a large number of set / getXXXX () function to set up, read the Animation of the property, which is shown in front of the table a variety of attributes. Tween Animation by the 4 types: alpha, scale, translate, roate, the Android SDK provides the appropriate class, Animation class derived the AlphaAnimation, ScaleAnimation, TranslateAnimation, RotateAnimation realized for translation, rotation, change the Alpha value on animation, Each sub-class basis in the parent class to add their own unique attributes. Go see next several class constructor that is not with us in Table 2, Table 3, Table 4, Table 5 kinds of attributes defined in exactly the same.
Android drawing study summary (4) - Animation (on)

Tween Animation in the understanding of the definition of the android.view.animation have some basic knowledge, we began to introduce the use of Tween Animation. Android SDK provides two kinds of ways: directly read from the XML resources Animation, Animation subclass use the constructor to initialize the Animation object, the second method of reading the Android SDK description of each class will know how to use the , the following brief description read from the XML resources Animation, in accordance with the application development process, describes the use of the process, as follows:

* Create Android projects;
* Import an image resources;
* Will be res \ layout \ main.xml the TextView replace ImageView;
* In the res to create a new folder under the anim, and in this folder the following definition of Animation XML documents;
* Modify the OnCreate () code, animation resources;

Key code, parsing the following:
/ / Main.xml the ImageView
ImageView spaceshipImage = (ImageView) findViewById (R.id.spaceshipImage);
/ / Load animation
Animation hyperspaceJumpAnimation =
AnimationUtils.loadAnimation (this, R.anim.hyperspace_jump);
/ / Animation using ImageView
spaceshipImage.startAnimation (hyperspaceJumpAnimation);
Project source code available to all downloads, download, here a brief analysis is as follows:

* AnimationUtils provides a loading animation function, in addition to function loadAnimation (), the other to the Android SDK in to learn more about it;
* The so-called animation, that is, the contents of the view do a graph transformation;

Summarizes the reading of this lengthy introduction, we detail the definition of the Tween Animation, using all the more in-depth understanding, because of space limitations, here's the contents of the Android SDK omitted a lot of, for example: Interpolator, and everyone Android SDK in themselves read.

相关文章
  • Android drawing study summary (4) - Animation (China) 2010-06-21

    Android drawing in learning conclusion (4) - Animation (I) described in detail Tween Animation in the definition, use, because of space limitations, many important respects not specified in this article on the one hand to be a complete summary descri

  • Android drawing study summary (4) - Animation (under) 2010-06-21

    Android drawing in learning conclusion (4) - Animation (on), we detail the Tween Aniamation, here we will introduce another animation Frame Animation. Said earlier, Frame Animation is to play in order to make proper image, with a similar film. Unlike

  • Android drawing study summary (4) - Animation (on) 2010-06-21

    With a deep understanding of the Drewable discovered Drawable more powerful features: Display Animation. Android SDK introduces two kinds of Animation: * Tween Animation: By constantly doing the scene where the object image transformation (translatio

  • Android drawing study summary (5) - Paint 2010-07-27

    Android drawing study summary (5) - Paint Previous drawing study concluded a series of Android , we were learning a Bitmap , Drawable , Aniamtion , in addition to the drawing elements, the development of applications using the most or the String (str

  • Android drawing study summary (1) - Class Description 2010-06-21

    Android for some time to learn, after reading most of the Android SDK documentation, but still lacks a lot of feel, later found, Android SDK is introduced in the development of that part of Google itself how to use, Android Java reference to the part

  • Android drawing study summary (3) - Drawable 2010-06-21

    Android SDK provides a powerful class Drawable, Drawable this abstract class in the end what it means and how to use? Drawable is a very abstract concept of a simple example program to study it, understand it. Look at a simple example, using the Draw

  • Android drawing study summary (2) - Bitmap 2010-06-21

    Through the former a study, drawing on the core of Android have a certain understanding of the back pages, we will detail the various drawing objects Android use, begin with our most popular Bitmap (bitmap). Bitmap is the most commonly used developme

  • android Data Storage (summary articles) 2010-09-01

    In the previous two articles: Android SQLite analysis , data sharing between applications Android , respectively, described in detail, how to use the database to store information, and how to access other applications through ContentProvider shared d

  • Android Intent usage summary 2010-04-12

    Android Intent usage summary Show page Uri uri = Uri.parse("http://google.com"); Intent it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it); Show map Uri uri = Uri.parse("geo:38.899533,-77.036476"); Intent it = new Intent(Inten

  • [To] Android drawing of the Matrix (c) 2011-05-24

    Original Address: http://developer.51cto.com/ In the Android operating system, there are many features tips to help us to easily implement some of the demand. Image processing such as image and so on. Here we will bring you some of the Android for th

  • android Study Summary 3 2010-03-29

    1 activity can be inherited extended ListActivity For example: class DummyNote extends ListActivity ( private String [] note_array = ( "gasolin", "crota", "louk", "magicion" ); ListAdapter adapter = new ArrayAdapter

  • Android 3D engine summary 2010-07-27

    Android Open Source 3D game engine to switch] [Summary 1. JPCT-AE Description: jPCT support the Android version. Website: http://www.jpct.net/jpct-ae/ 2. Kwwaak3 Description: Quake 3 ported to Android platform mobile phone features: sound, network, O

  • Android recent study concluded - development ready 2010-10-26

    Contact android has more than 1 month's time. Rush into battle, there are a lot of unfamiliar places. Written summary of the recent study are: I. Background: OMS is based on an Android open mobile phone platform. Led by the Google, the major hardware

  • Android Intent comprehensive summary of several usage (transfer) 2010-06-08

    Android Intent use a comprehensive summary of several Intent should be something peculiar to Android. You can specify the procedures Intent to perform actions (such as: view, edit, dial), and the program execution to the action when the required info

  • java study summary (1) 2010-08-12

    2010-7-27 --- 2010-8-12 Needs to summarize the contents: 1. Inheritance, polymorphism, rewrite? Inheritance: There is already a parent the parent class, child class to call the parent class's methods and properties, with the extends keyword public so

  • Android's Handler Summary 2010-08-19

    <1> Handler's definition: Major sub-thread to send the data received and used this data with the main thread update UI. Explanation: When the application starts, Android will first open a main thread (UI thread that is), the main thread for the mana

  • Android permissions mechanism summary and analysis of common problem of insufficient permissions 2010-08-29

    Android system is running on the Linux kernel, Android and Linux each have their own set of strict security and permissions system, Many novice like me, especially the low security restriction used to windows users, it is easy to get confused in this

  • Android drawing of the Matrix (b) 2010-10-23

    Android on a drawing of the Matrix (a) Matrix spoke about the principles and calculation methods, related to higher mathematics, a bit difficult to understand. Fortunately Android Matrix which provides a series of operations Out convenient interface.

  • Android drawing of the anti-aliasing 2010-10-26

    In the drawing, when rotating or scaling if after pictures will always be those gorgeous teeth. Android comes with a solution in fact. Method One: to Paint with antialiasing flag. Paint the object and then drawing canvas as a parameter to methods. pa

  • Android drawing of the anti-aliasing (to) 2010-11-10

    In the drawing, when rotating or scaling if after pictures will always be those gorgeous teeth. Android comes with a solution in fact. Method One: to Paint with antialiasing flag. Paint the object and then drawing canvas as a parameter to methods. Ja