SlideServe
Menu
Préférences
© SlideServe · v2026

Animations

muniya avatar
13 diapositives · 432 Views · Jul 27, 2014

Animations. Animation Category . Tweened Animations Scale animations Rotate animations Alpha animations Translate animations Frame-by-Frame Animations. Procedure to create Tweened Animations. Create an object of AnimationSet Create an object of Animation

Animations - slide 1
01 / 13Animations
1 / 17

Télécharger la présentation

Animations
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Animations Fall 2012 CS2302: Programming Principles

  2. Animation Category • Tweened Animations • Scale animations • Rotate animations • Alpha animations • Translate animations • Frame-by-Frame Animations Fall 2012 CS2302: Programming Principles

  3. Procedure to create Tweened Animations • Create an object of AnimationSet • Create an object of Animation • TranslateAnimation(intfromXType, float fromXValue, inttoXType, float toXValue, intfromYType, float fromYValue, inttoYType, float toYValue) • AlphaAnimation(float fromAlpha, float toAlpha) • ScaleAnimation(float fromX, float toX, float fromY, float toY, intpivotXType, float pivotXValue, intpivotYType, float pivotYValue) • RotateAnimation(float fromDegrees, float toDegrees, intpivotXType, float pivotXValue, intpivotYType, float pivotYValue) • Setting parameters for the object of Animation • Add the object of Animation to the object of AnimationSet • startAnimation(animationSet); Fall 2012 CS2302: Programming Principles

  4. Attributes of Animations Fall 2012 CS2302: Programming Principles

  5. Common Methods of Tweened Animations • setDuration(long durationMills) • set the amount of time (in milliseconds) for the animation to run • setFillAfter(booleanfillAfter) • If fillAfter is set to true, then the animation transformation is applied after the animation is over. • setFillBefore(booleanfillBefore) • If fillBeforeis set to true, then the animation transformation is applied before the animation has started. • setStartOffSet(long startOffset) • Set the delay in milliseconds before the animation runs. • setRepeatCount(intrepeatCount) • Defines how many times the animation should repeat. Fall 2012 CS2302: Programming Principles

  6. Create Tweened Animations by editing xml file • Create a folder called anim under res folder • Create new xml files in the anim folder. Add a set tag in the xml files: <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> </set> • Add rotate, alpha, scale, or translate tag in the set tag. • Use AnimationUtils.loadAnimation to load the xml file, and then create an object of Animation • startAnimation Fall 2012 CS2302: Programming Principles

  7. Alpha Animation’s xml file <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:startOffset="500" android:duration="500" /> </set> Fall 2012 CS2302: Programming Principles

  8. Rotate Animation’s xml file <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <rotate android:fromDegrees="0" android:toDegrees="360" android:pivotX="50%" android:pivotY="50%" android:duration="5000" /> </set> Fall 2012 CS2302: Programming Principles

  9. Translate Animation’s xml file <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <translate android:fromXDelta="50%" android:toXDelta="100%" android:fromYDelta="0%" android:toYDelta="100%" android:duration="2000" /> </set> Fall 2012 CS2302: Programming Principles

  10. Scale Animation’s xml file <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <scale android:fromXScale="1.0" android:toXScale="0.0" android:fromYScale="1.0" android:toYScale="0.0" android:pivotX="50%" android:pivotY="50%" android:duration="2000" /> </set> Fall 2012 CS2302: Programming Principles

  11. Load xml file • In the MainActivity.java file • Animation animation = (Animation) AnimationUtils.loadAnimation(MainActivity.this, R.anim.translate); • imageView.startAnimation(animation); Fall 2012 CS2302: Programming Principles

  12. Frame-By-Frame Animations • Create a xml file under res/drawable <animation-listxmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> <item android:drawable="@drawable/nv1" android:duration="500" /> <item android:drawable="@drawable/nv2" android:duration="500" /> <item android:drawable="@drawable/nv3" android:duration="500" /> <item android:drawable="@drawable/nv4" android:duration="500" /> </animation-list> Fall 2012 CS2302: Programming Principles

  13. Frame-By-Frame Animations • Load the xml file • imageView.setBackgroundResource(R.drawable.anim); • Get AnimationDrawable • AnimationDrawableanimationDrawable = (AnimationDrawable)imageView.getBackground(); • Start the animation • animatinDrawable.start(); Fall 2012 CS2302: Programming Principles