Android Animation Resources Detailed

Source: Internet
Author: User

Property animations:
  • Causes an object's property value to change to a value within a certain time interval.
  • Http://developer.android.com/guide/topics/resources/animation-resource.html#Property
Resources Catalog: Rec\animator
    <set xmlns:android="http://schemas.android.com/apk/res/android"        android:ordering="sequentially" >   // together|sequentially        <objectAnimator            android:duration="2000"            android:propertyName="y"            android:valueTo="300"            android:valueType="intType" />        <objectAnimator            android:duration="3000"            android:propertyName="x"            android:valueTo="220"            android:valueType="intType" />    
To create an attribute class for an app
    class Move    {        private int y;        private int x;        public int getY()        {              return y;        }        public void setY(int y)        {            this.y = y;            button.layout(button.getLeft(), y, button.getRight(),                    y + button.getMeasuredHeight());        }        public int getX()        {            return x;        }        public void setX(int x)        {            this.x = x;            button.layout(x, button.getTop(), x + button.getMeasuredWidth(),                    button.getBottom());        }    }
Load resources and perform animations
    // 装载属性动画资源    AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(this,            R.animator.property_anim);    // 设置要控制的对象    set.setTarget(move);    // 开始动画    set.start();
Frame animations:
  • Animations occur when a static image is continuously played at high frequencies
  • Http://developer.android.com/guide/topics/resources/animation-resource.html#Frame
Resources Catalog: res/drawable/
  • Frame animation must use <animation-list> tag as root node
  • Android:oneshot= "false" for Infinite loop playback, android:oneshot= "true": Play Once
  • The first one represents a static image
  • android:duration= "100": Specifies the time at which the current image stays

Example one:

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"    android:oneshot="false">    <item android:drawable="@drawable/myanim1" android:duration="20" />    <item android:drawable="@drawable/myanim2" android:duration="20" />    <item android:drawable="@drawable/myanim3" android:duration="20" />    <item android:drawable="@drawable/myanim4" android:duration="20" />    <item android:drawable="@drawable/myanim5" android:duration="20" />    <item android:drawable="@drawable/myanim6" android:duration="20" /></animation-list>
Motion Tweens:
  • Animated effect when a static image is played continuously at high frequency (Res/anim)
  • Http://developer.android.com/guide/topics/resources/animation-resource.html#Tween
Resources Catalog: res/anim/
<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android"     android:interpolator= "@[package:]anim/interpolator_resource"     android:shareinterpolator= ["True" | "False" >    <alpha        android:fromalpha= "float"         Android Oid:toalpha= "float"/>    <scale        android:fromxscale= "float"     & nbsp   android:toxscale= "float"         android:fromyscale= "float"         android:toyscale= "float"         android:pivotx= "float"         android:pivoty= " Float "/>    <translate        android:fromxdelta=" float "        Android:toxdelta= "float"         android:fromydelta= "float"         Android: Toydelta= "float"/>    <rotate  &NBSp     android:fromdegrees= "float"         android:todegrees= "float"         android:pivotx= "float"         android:pivoty= "float"/>    <set>  & nbsp     ...    </set></set>
Animation renderer

Definition: Used to modify the animation effect, define the rate of change of animation, can make the existing animation effect accelerated (acceleration), decelerated (deceleration), repeated (repetition), bounced (bounce) and so on.

    • Acceleratedecelerateinterpolator at the beginning of the animation with the introduction of the local rate change slower, in the middle of the time to accelerate
    • Accelerateinterpolator at the beginning of the animation the rate change is slow, and then start to accelerate
    • Anticipateinterpolator starts back and then moves forward.
    • Anticipateovershootinterpolator starts back and then dumps a certain value and returns the last value.
    • Bounceinterpolator animation at the end of the play
    • Cycleinterpolator Animation Loop plays a specific number of times, rate changes along the sine curve
    • Decelerateinterpolator in the beginning of the animation and then slowly
    • Linearinterpolator change at constant rate
    • Overshootinterpolator forward a certain value before returning to its original position.

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.