SlideShare una empresa de Scribd logo
1 de 23
Android Programming




     Lesson 13

Android Animation
    NGUYEN The Linh
Android Programming


Contents


       1   Property Animation

       2   Drawable Animation

       3   View Animation




                         2
Android Programming


Android Animation




            Property Animation




                    3
Android Programming


Property Animation

 Animating with ValueAnimator
    The ValueAnimator class lets you animate values of some type
     for the duration of an animation by specifying a set of int, float, or
     color values to animate through. You obtain a ValueAnimator by
     calling one of its factory methods: ofInt(), ofFloat(), or ofObject().
     For example:




                                   4
Android Programming


Property Animation

 Animating with ValueAnimator
    The previous code snippets, however, has no real effect on an
     object, because the ValueAnimator does not operate on objects
     or properties directly.

    You do this by defining listeners in the ValueAnimator to
     appropriately handle important events during the animation's
     lifespan, such as frame updates.




                                 5
Android Programming


Property Animation

 Animating with ValueAnimator
    When implementing the listeners, you can obtain the calculated
     value for that specific frame refresh by calling
     getAnimatedValue()

    Animator.AnimatorListener
       • onAnimationStart() - Called when the animation starts.

       • onAnimationEnd() - Called when the animation ends.

       • onAnimationRepeat() - Called when the animation repeats itself.

                                      6
Android Programming


Property Animation

 Animating with ValueAnimator
    Animator.AnimatorListener
     • onAnimationCancel() - Called when the animation is canceled. A cancelled
       animation also calls onAnimationEnd(), regardless of how they were ended.


   ValueAnimator.AnimatorUpdateListener
     • onAnimationUpdate() - called on every frame of the animation.




                                    7
Android Programming


Property Animation

 Animating with ObjectAnimator
    The ObjectAnimator is a subclass of
     he ValueAnimator (discussed in the previous section) and
     combines the timing engine and value computation
     of ValueAnimator with the ability to animate a named property of
     a target object.




                                 8
Android Programming


Property Animation

 Choreographing Multiple Animations with AnimatorSet
    In many cases, you want to play an animation that depends on
     when another animation starts or finishes.

    The Android system lets you bundle animations together into
     an AnimatorSet, so that you can specify whether to start
     animations simultaneously, sequentially, or after a specified delay.

    You can also nest AnimatorSet objects within each other.


                                  9
Android Programming


Property Animation

 Choreographing Multiple Animations with AnimatorSet




                         10
Android Programming


Property Animation

 Choreographing Multiple Animations with AnimatorSet
    1. Plays bounceAnim.

   2. Plays squashAnim1, squashAnim2, stretchAnim1,
    and stretchAnim2 at the same time.

   3. Plays bounceBackAnim.

   4. Plays fadeAnim.


                               11
Android Programming


Property Animation

 Example 13.1




                     12
Android Programming


Android Animation




           Drawable Animation




                    13
Android Programming


Drawable Animation

 Drawable animation lets you load a series of Drawable
  resources one after another to create an animation.

 This is a traditional animation in the sense that it is created
  with a sequence of different images, played in order, like a
  roll of film



 The AnimationDrawable class is the basis for Drawable
  animations.

                               14
Android Programming


Drawable Animation

 While you can define the frames of an animation in your
  code, using the AnimationDrawable class API, it's more
  simply accomplished with a single XML file that lists the
  frames that compose the animation.

 The XML file for this kind of animation belongs in
  the res/drawable/ directory of your Android project.




                             15
Android Programming


Drawable Animation




                     16
Android Programming


Drawable Animation

 Example 13.2




                     17
Android Programming


Android Animation




             View Animation




                    18
Android Programming


View Animation

 You can use the view animation system to perform tweened
  animation on Views.

 Tween animation calculates the animation with information
  such as the start point, end point, size, rotation, and
  other common aspects of an animation.




                            19
Android Programming


View Animation

 There are two types of animations that you can do with the
  view animation framework:

    Tween animation: Creates an animation by performing a series of
     transformations on a single image with an Animation

    Frame animation: or creates an animation by showing a
     sequence of images in order with an AnimationDrawable.




                               20
Android Programming


View Animation

 The animation XML file belongs in the res/anim/ directory
  of your Android project.

 The file must have a single root element: this will be either a
  single <alpha>, <scale>, <translate>, <rotate>,
  interpolator element, or<set> element that holds groups of
  these elements (which may include another <set>).




                              21
Android Programming


View Animation

 Example 13.3




                 22
Android Programming

Más contenido relacionado

La actualidad más candente

android activity
android activityandroid activity
android activityDeepa Rani
 
Introduction to Android and Android Studio
Introduction to Android and Android StudioIntroduction to Android and Android Studio
Introduction to Android and Android StudioSuyash Srijan
 
Android resource
Android resourceAndroid resource
Android resourceKrazy Koder
 
Android Lesson 3 - Intent
Android Lesson 3 - IntentAndroid Lesson 3 - Intent
Android Lesson 3 - IntentDaniela Da Cruz
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/ServletSunil OS
 
Supporting multiple screens on android
Supporting multiple screens on androidSupporting multiple screens on android
Supporting multiple screens on androidLi SUN
 
Android activity
Android activityAndroid activity
Android activityKrazy Koder
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in androidPrawesh Shrestha
 
Android Crash analysis and The Dalvik Garbage collector – Tools and Tips
Android Crash analysis and The Dalvik Garbage collector – Tools and TipsAndroid Crash analysis and The Dalvik Garbage collector – Tools and Tips
Android Crash analysis and The Dalvik Garbage collector – Tools and TipsDroidConTLV
 
DDD와 이벤트소싱
DDD와 이벤트소싱DDD와 이벤트소싱
DDD와 이벤트소싱Suhyeon Jo
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycleSoham Patel
 
Android Architecture
Android ArchitectureAndroid Architecture
Android Architecturedeepakshare
 

La actualidad más candente (20)

android activity
android activityandroid activity
android activity
 
Introduction to Android and Android Studio
Introduction to Android and Android StudioIntroduction to Android and Android Studio
Introduction to Android and Android Studio
 
AndroidManifest
AndroidManifestAndroidManifest
AndroidManifest
 
Android - Android Intent Types
Android - Android Intent TypesAndroid - Android Intent Types
Android - Android Intent Types
 
Android Intent.pptx
Android Intent.pptxAndroid Intent.pptx
Android Intent.pptx
 
Android resource
Android resourceAndroid resource
Android resource
 
Android Location and Maps
Android Location and MapsAndroid Location and Maps
Android Location and Maps
 
Android Lesson 3 - Intent
Android Lesson 3 - IntentAndroid Lesson 3 - Intent
Android Lesson 3 - Intent
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
 
Supporting multiple screens on android
Supporting multiple screens on androidSupporting multiple screens on android
Supporting multiple screens on android
 
05 intent
05 intent05 intent
05 intent
 
Android activity
Android activityAndroid activity
Android activity
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
 
Introduction to android testing
Introduction to android testingIntroduction to android testing
Introduction to android testing
 
Android Crash analysis and The Dalvik Garbage collector – Tools and Tips
Android Crash analysis and The Dalvik Garbage collector – Tools and TipsAndroid Crash analysis and The Dalvik Garbage collector – Tools and Tips
Android Crash analysis and The Dalvik Garbage collector – Tools and Tips
 
DDD와 이벤트소싱
DDD와 이벤트소싱DDD와 이벤트소싱
DDD와 이벤트소싱
 
Ordbms
OrdbmsOrdbms
Ordbms
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
 
Android Architecture
Android ArchitectureAndroid Architecture
Android Architecture
 

Destacado

Presentation animation android
Presentation animation android Presentation animation android
Presentation animation android Nadim GOUIA
 
Android App Development - 12 animations
Android App Development - 12 animationsAndroid App Development - 12 animations
Android App Development - 12 animationsDiego Grancini
 
Introduction to Android Animations
Introduction to Android AnimationsIntroduction to Android Animations
Introduction to Android AnimationsXamarin
 
Android Training (Animation)
Android Training (Animation)Android Training (Animation)
Android Training (Animation)Khaled Anaqwa
 
Presentation on Android operating system
Presentation on Android operating systemPresentation on Android operating system
Presentation on Android operating systemSalma Begum
 

Destacado (7)

Presentation animation android
Presentation animation android Presentation animation android
Presentation animation android
 
Android App Development - 12 animations
Android App Development - 12 animationsAndroid App Development - 12 animations
Android App Development - 12 animations
 
Android animation theory
Android animation theoryAndroid animation theory
Android animation theory
 
Introduction to Android Animations
Introduction to Android AnimationsIntroduction to Android Animations
Introduction to Android Animations
 
Android Training (Animation)
Android Training (Animation)Android Training (Animation)
Android Training (Animation)
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Presentation on Android operating system
Presentation on Android operating systemPresentation on Android operating system
Presentation on Android operating system
 

Similar a [Android] Android Animation

Animation in android
Animation in androidAnimation in android
Animation in androidJatin_123
 
Seven Peaks Speaks - Android Jetpack Compose Animation
Seven Peaks Speaks - Android Jetpack Compose AnimationSeven Peaks Speaks - Android Jetpack Compose Animation
Seven Peaks Speaks - Android Jetpack Compose AnimationSeven Peaks Speaks
 
Android animations
Android animationsAndroid animations
Android animationsKumar
 
Top Tips for Android UIs - Getting the Magic on Tablets
Top Tips for Android UIs - Getting the Magic on TabletsTop Tips for Android UIs - Getting the Magic on Tablets
Top Tips for Android UIs - Getting the Magic on TabletsMotorola Mobility - MOTODEV
 
Basic Android Animation
Basic Android Animation Basic Android Animation
Basic Android Animation Shilu Shrestha
 
[Android] 2D Graphics
[Android] 2D Graphics[Android] 2D Graphics
[Android] 2D GraphicsNikmesoft Ltd
 
Computer animation Computer Graphics
Computer animation Computer Graphics Computer animation Computer Graphics
Computer animation Computer Graphics University of Potsdam
 
Advance ui development and design
Advance ui  development and design Advance ui  development and design
Advance ui development and design Rakesh Jha
 
[Android] Basic Widgets and Containers
[Android] Basic Widgets and Containers[Android] Basic Widgets and Containers
[Android] Basic Widgets and ContainersNikmesoft Ltd
 
Getting started with Verold and Three.js
Getting started with Verold and Three.jsGetting started with Verold and Three.js
Getting started with Verold and Three.jsVerold
 
Implementing a Splash Screen in Android: Full Guide
Implementing a Splash Screen in Android: Full GuideImplementing a Splash Screen in Android: Full Guide
Implementing a Splash Screen in Android: Full GuideDean Djermanovic
 
Trends in Computer Graphics
Trends in Computer GraphicsTrends in Computer Graphics
Trends in Computer GraphicsSajal Maharjan
 

Similar a [Android] Android Animation (20)

Animation in android
Animation in androidAnimation in android
Animation in android
 
Seven Peaks Speaks - Android Jetpack Compose Animation
Seven Peaks Speaks - Android Jetpack Compose AnimationSeven Peaks Speaks - Android Jetpack Compose Animation
Seven Peaks Speaks - Android Jetpack Compose Animation
 
Android - Graphics Animation in Android
Android - Graphics Animation in AndroidAndroid - Graphics Animation in Android
Android - Graphics Animation in Android
 
Android animation in android-chapter17
Android animation in android-chapter17Android animation in android-chapter17
Android animation in android-chapter17
 
Android animations
Android animationsAndroid animations
Android animations
 
Top Tips for Android UIs - Getting the Magic on Tablets
Top Tips for Android UIs - Getting the Magic on TabletsTop Tips for Android UIs - Getting the Magic on Tablets
Top Tips for Android UIs - Getting the Magic on Tablets
 
Basic Android Animation
Basic Android Animation Basic Android Animation
Basic Android Animation
 
[Android] 2D Graphics
[Android] 2D Graphics[Android] 2D Graphics
[Android] 2D Graphics
 
Computer animation Computer Graphics
Computer animation Computer Graphics Computer animation Computer Graphics
Computer animation Computer Graphics
 
Animation
AnimationAnimation
Animation
 
Advance ui development and design
Advance ui  development and design Advance ui  development and design
Advance ui development and design
 
ANIMATION SEQUENCE
ANIMATION SEQUENCEANIMATION SEQUENCE
ANIMATION SEQUENCE
 
3.2 ws WMS.pdf
3.2 ws WMS.pdf3.2 ws WMS.pdf
3.2 ws WMS.pdf
 
[Android] Basic Widgets and Containers
[Android] Basic Widgets and Containers[Android] Basic Widgets and Containers
[Android] Basic Widgets and Containers
 
Android view animation in android-chapter18
Android view animation in android-chapter18Android view animation in android-chapter18
Android view animation in android-chapter18
 
Getting started with Verold and Three.js
Getting started with Verold and Three.jsGetting started with Verold and Three.js
Getting started with Verold and Three.js
 
Android canvas-chapter20
Android canvas-chapter20Android canvas-chapter20
Android canvas-chapter20
 
Implementing a Splash Screen in Android: Full Guide
Implementing a Splash Screen in Android: Full GuideImplementing a Splash Screen in Android: Full Guide
Implementing a Splash Screen in Android: Full Guide
 
The world of Android Animations
The world of Android AnimationsThe world of Android Animations
The world of Android Animations
 
Trends in Computer Graphics
Trends in Computer GraphicsTrends in Computer Graphics
Trends in Computer Graphics
 

Más de Nikmesoft Ltd

[iOS] Multiple Background Threads
[iOS] Multiple Background Threads[iOS] Multiple Background Threads
[iOS] Multiple Background ThreadsNikmesoft Ltd
 
[iOS] Basic UI Elements
[iOS] Basic UI Elements[iOS] Basic UI Elements
[iOS] Basic UI ElementsNikmesoft Ltd
 
[iOS] Introduction to iOS Programming
[iOS] Introduction to iOS Programming[iOS] Introduction to iOS Programming
[iOS] Introduction to iOS ProgrammingNikmesoft Ltd
 
[Android] Multimedia Programming
[Android] Multimedia Programming[Android] Multimedia Programming
[Android] Multimedia ProgrammingNikmesoft Ltd
 
[Android] Services and Broadcast Receivers
[Android] Services and Broadcast Receivers[Android] Services and Broadcast Receivers
[Android] Services and Broadcast ReceiversNikmesoft Ltd
 
[Android] Web services
[Android] Web services[Android] Web services
[Android] Web servicesNikmesoft Ltd
 
[Android] Multiple Background Threads
[Android] Multiple Background Threads[Android] Multiple Background Threads
[Android] Multiple Background ThreadsNikmesoft Ltd
 
[Android] Maps, Geocoding and Location-Based Services
[Android] Maps, Geocoding and Location-Based Services[Android] Maps, Geocoding and Location-Based Services
[Android] Maps, Geocoding and Location-Based ServicesNikmesoft Ltd
 
[Android] Data Storage
[Android] Data Storage[Android] Data Storage
[Android] Data StorageNikmesoft Ltd
 
[Android] Intent and Activity
[Android] Intent and Activity[Android] Intent and Activity
[Android] Intent and ActivityNikmesoft Ltd
 
[Android] Widget Event Handling
[Android] Widget Event Handling[Android] Widget Event Handling
[Android] Widget Event HandlingNikmesoft Ltd
 
[Android] Using Selection Widgets
[Android] Using Selection Widgets[Android] Using Selection Widgets
[Android] Using Selection WidgetsNikmesoft Ltd
 
[Android] Introduction to Android Programming
[Android] Introduction to Android Programming[Android] Introduction to Android Programming
[Android] Introduction to Android ProgrammingNikmesoft Ltd
 

Más de Nikmesoft Ltd (16)

[iOS] Networking
[iOS] Networking[iOS] Networking
[iOS] Networking
 
[iOS] Data Storage
[iOS] Data Storage[iOS] Data Storage
[iOS] Data Storage
 
[iOS] Multiple Background Threads
[iOS] Multiple Background Threads[iOS] Multiple Background Threads
[iOS] Multiple Background Threads
 
[iOS] Navigation
[iOS] Navigation[iOS] Navigation
[iOS] Navigation
 
[iOS] Basic UI Elements
[iOS] Basic UI Elements[iOS] Basic UI Elements
[iOS] Basic UI Elements
 
[iOS] Introduction to iOS Programming
[iOS] Introduction to iOS Programming[iOS] Introduction to iOS Programming
[iOS] Introduction to iOS Programming
 
[Android] Multimedia Programming
[Android] Multimedia Programming[Android] Multimedia Programming
[Android] Multimedia Programming
 
[Android] Services and Broadcast Receivers
[Android] Services and Broadcast Receivers[Android] Services and Broadcast Receivers
[Android] Services and Broadcast Receivers
 
[Android] Web services
[Android] Web services[Android] Web services
[Android] Web services
 
[Android] Multiple Background Threads
[Android] Multiple Background Threads[Android] Multiple Background Threads
[Android] Multiple Background Threads
 
[Android] Maps, Geocoding and Location-Based Services
[Android] Maps, Geocoding and Location-Based Services[Android] Maps, Geocoding and Location-Based Services
[Android] Maps, Geocoding and Location-Based Services
 
[Android] Data Storage
[Android] Data Storage[Android] Data Storage
[Android] Data Storage
 
[Android] Intent and Activity
[Android] Intent and Activity[Android] Intent and Activity
[Android] Intent and Activity
 
[Android] Widget Event Handling
[Android] Widget Event Handling[Android] Widget Event Handling
[Android] Widget Event Handling
 
[Android] Using Selection Widgets
[Android] Using Selection Widgets[Android] Using Selection Widgets
[Android] Using Selection Widgets
 
[Android] Introduction to Android Programming
[Android] Introduction to Android Programming[Android] Introduction to Android Programming
[Android] Introduction to Android Programming
 

Último

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Último (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

[Android] Android Animation

  • 1. Android Programming Lesson 13 Android Animation NGUYEN The Linh
  • 2. Android Programming Contents 1 Property Animation 2 Drawable Animation 3 View Animation 2
  • 4. Android Programming Property Animation  Animating with ValueAnimator  The ValueAnimator class lets you animate values of some type for the duration of an animation by specifying a set of int, float, or color values to animate through. You obtain a ValueAnimator by calling one of its factory methods: ofInt(), ofFloat(), or ofObject(). For example: 4
  • 5. Android Programming Property Animation  Animating with ValueAnimator  The previous code snippets, however, has no real effect on an object, because the ValueAnimator does not operate on objects or properties directly.  You do this by defining listeners in the ValueAnimator to appropriately handle important events during the animation's lifespan, such as frame updates. 5
  • 6. Android Programming Property Animation  Animating with ValueAnimator  When implementing the listeners, you can obtain the calculated value for that specific frame refresh by calling getAnimatedValue()  Animator.AnimatorListener • onAnimationStart() - Called when the animation starts. • onAnimationEnd() - Called when the animation ends. • onAnimationRepeat() - Called when the animation repeats itself. 6
  • 7. Android Programming Property Animation  Animating with ValueAnimator  Animator.AnimatorListener • onAnimationCancel() - Called when the animation is canceled. A cancelled animation also calls onAnimationEnd(), regardless of how they were ended.  ValueAnimator.AnimatorUpdateListener • onAnimationUpdate() - called on every frame of the animation. 7
  • 8. Android Programming Property Animation  Animating with ObjectAnimator  The ObjectAnimator is a subclass of he ValueAnimator (discussed in the previous section) and combines the timing engine and value computation of ValueAnimator with the ability to animate a named property of a target object. 8
  • 9. Android Programming Property Animation  Choreographing Multiple Animations with AnimatorSet  In many cases, you want to play an animation that depends on when another animation starts or finishes.  The Android system lets you bundle animations together into an AnimatorSet, so that you can specify whether to start animations simultaneously, sequentially, or after a specified delay.  You can also nest AnimatorSet objects within each other. 9
  • 10. Android Programming Property Animation  Choreographing Multiple Animations with AnimatorSet 10
  • 11. Android Programming Property Animation  Choreographing Multiple Animations with AnimatorSet  1. Plays bounceAnim.  2. Plays squashAnim1, squashAnim2, stretchAnim1, and stretchAnim2 at the same time.  3. Plays bounceBackAnim.  4. Plays fadeAnim. 11
  • 13. Android Programming Android Animation Drawable Animation 13
  • 14. Android Programming Drawable Animation  Drawable animation lets you load a series of Drawable resources one after another to create an animation.  This is a traditional animation in the sense that it is created with a sequence of different images, played in order, like a roll of film  The AnimationDrawable class is the basis for Drawable animations. 14
  • 15. Android Programming Drawable Animation  While you can define the frames of an animation in your code, using the AnimationDrawable class API, it's more simply accomplished with a single XML file that lists the frames that compose the animation.  The XML file for this kind of animation belongs in the res/drawable/ directory of your Android project. 15
  • 19. Android Programming View Animation  You can use the view animation system to perform tweened animation on Views.  Tween animation calculates the animation with information such as the start point, end point, size, rotation, and other common aspects of an animation. 19
  • 20. Android Programming View Animation  There are two types of animations that you can do with the view animation framework:  Tween animation: Creates an animation by performing a series of transformations on a single image with an Animation  Frame animation: or creates an animation by showing a sequence of images in order with an AnimationDrawable. 20
  • 21. Android Programming View Animation  The animation XML file belongs in the res/anim/ directory of your Android project.  The file must have a single root element: this will be either a single <alpha>, <scale>, <translate>, <rotate>, interpolator element, or<set> element that holds groups of these elements (which may include another <set>). 21