When we do the APK development process, if you want to attract users, we need to make a very good interface, of course, animation is essential, then the recording and learning animation related ...
Next, some things in the usual, slowly upload up, do a record and save
The first one to be explained today is the Scaleanimation (zoom animation) in the View animation
It allows the view to zoom in and out, the corresponding class is scaleanimation, inherits from animation
<scale> label scaling animation, corresponding to the scaleanimation,
It has a series of properties
1 <?XML version= "1.0" encoding= "Utf-8"?>2 3 < Scalexmlns:android= "Http://schemas.android.com/apk/res/android"4 5 Android:fromxscale= "0.0"#起始x尺寸比例6 7 Android:toxscale= "1.4"#最终x尺寸比例8 9 Android:fromyscale= "0.0"#起始y尺寸比例Ten One Android:toyscale= "1.4"#最终y尺寸比例 A - Android:pivotx= "50%"#缩放起点x轴坐标, the value can be a number (50), a percentage (50%), a percentage p (50%p), when the value is a number, the zoom start point is the upper left corner of the view coordinates plus a specific number of pixels, when the value is a percentage, the upper left corner of the current view to sit Plus a specific percentage of the view width, when the value is a percentage p, the specified percentage of the upper-left coordinate of the view plus the width of the parent control - the Android:pivoty= "50%"#同上 - - android:duration= "The "#动画持续时间, in milliseconds - + Android:fillafter= "true"#动画结束后, keep the state at the end - + Android:fillbefore= "true"#动画结束后, revert to the initial state A at android:fillenabled= "true"#效果同上 - - Android:repeatcount= "5"#重复次数, the value is 1 infinite repetition, the default animation is executed once - - Android:repeatmode= "Reverse"#重复模式, there are reverse and restart two values, the former is reverse playback, the latter is a restart - in Android::interpolator= "@android: Anim/accelerate_decelerate_interpolator"#插值器 affect the speed of the animation this property can not be specified, the default is the accelerated deceleration differential/>
is divided into two types: the use of XML, the use of code
- How XML is used:
First step: Create a new Anim folder underneath the Res directory and create a new XML file in it, such as
Step Two: Add the appropriate properties as needed
1 <?XML version= "1.0" encoding= "Utf-8"?>2 < Scalexmlns:android= "Http://schemas.android.com/apk/res/android"3 Android:fromxscale= "0.0"4 Android:toxscale= "1.4"5 Android:fromyscale= "0.0"6 Android:toyscale= "1.4"7 Android:pivotx= "0"8 Android:pivoty= "50%"9 android:duration= "+"Ten Android:repeatcount= "4" One Android:repeatmode= "Reverse" A Android:interpolator= "@android: Anim/accelerate_decelerate_interpolator" - />
The third step is to use XML in your code
1 TV = Findviewbyid (r.id.tv); 2 Animation Animation = animationutils.loadanimation (this,r.anim.scalefile); 3 tv.startanimation (animation);
Use the Scaleanimation class directly in your code to use the Zoom animation:
1 scaleanimation scaleanimation = new Scaleanimation (1,1.4f,1,1.4f,0.5f,0.5f); 2 scaleanimation.setduration (+); 3 Scaleanimation.setrepeatcount (4); 4 Scaleanimation.setrepeatmode (animation.reverse); 5 tv.startanimation (scaleanimation);
About Scaleanimation first down here, you need to download the source code https://github.com/yangmtou/AnimationForAndroid
Android View Animation (i)---scale