SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler offline
Android Animation
Topics
• Frame by Frame animation
• Tween animation
> Translate, Rotate, Scale, Alpha
• Interpolator
• Layout animation
Frame-by-Frame Animationnim
What is Frame-by-Frame Animation?
• Created with a sequence of different images,
played in order, like a roll of film.
• Pieces
> The frames in the /res/drawable directory
> Animation resource XML file in which the frames
are specified as <item> under <animation-list>
> Code that loads the Animation resource XML file
Animation XML Resource
• The XML file consists of an <animation-list>
element as the root node and a series of child
<item> nodes that each define a frame
<?xml version="1.0" encoding="UTF-8"?>
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
id="selected" android:oneshot="false">
<item android:drawable="@drawable/ball1" android:duration="50" />
<item android:drawable="@drawable/ball2" android:duration="50" />
<item android:drawable="@drawable/ball3" android:duration="50" />
<item android:drawable="@drawable/ball4" android:duration="50" />
<item android:drawable="@drawable/ball5" android:duration="50" />
<item android:drawable="@drawable/ball6" android:duration="50" />
</animation-list>
Code That Starts the Animation
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.framebyframe);
// Load the ImageView that will host the animation and
// set its background to the AnimationDrawable XML resource.
ImageView img = (ImageView) findViewById(R.id.my_image_view);
img.setBackgroundResource(R.anim.simple_animation);
// Get the background, which has been compiled to an AnimationDrawable object.
frameAnimation = (AnimationDrawable) img.getBackground();
}
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (animationStarted){
frameAnimation.stop();
animationStarted = false;
}
else{
frameAnimation.start();
animationStarted = true;
}
return true;
}
return super.onTouchEvent(event);
Tween Animationnimation
Built-in Tween Animation Schemes
• TransitionAnimation
> Position change
• RotateAnimation
> Rotation
• ScaleAnimation
> Scaling
• AlphaAnimation
> Transparancy
Steps of Tween Animation
• Create XML animation resource file in
/res/anim/ directory
• Load the XML animation resource file into
Animation object
• Start the animation
Create Animation XML Resource
• The XML file is located under /res/anim/ directory
• Example below is for Rotate animation
<?xml version="1.0" encoding="UTF-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromDegrees="0"
android:toDegrees="270"
android:toYScale="0.0"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="700"
android:duration="700" />
Create Animation XML Resource
• Sequential animation is done with <set>
• Example below - Translate animation followed by
Rotate animation
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="0"
android:toXDelta="100"
android:fromYDelta="0"
android:toYDelta="150"
android:duration="1000" />
<rotate
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromDegrees="0"
android:toDegrees="270"
android:toYScale="0.0"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="700"
android:duration="700" />
</set>
Loading Animation Resource &
Staring Animation
// Load Animation object from a resource
Animation rotate = AnimationUtils.loadAnimation(this,
R.anim.rotate);
// Select the animation target and start the animation
findViewById(R.id.myimage).startAnimation(rotate);
Interpolatornterpolator
What is Interpolator
• An interpolator defines the rate of change of an
animation.
• This allows the basic animation effects (alpha,
scale, translate, rotate) to be accelerated,
decelerated, repeated, etc.
• You can set an interpolator either in XML
animation resource file or programmatically
Built-in Android Interpolators
• Built-in Android Interpolators
> android.R.anim.accelerate_interpolator
> android.R.anim.decelerate_interpolator
> android.R.anim.accelerate_decelerate_interpolator
> android.R.anim.anticipate_interpolator
> android.R.anim.overshoot_interpolator
• Example of setting interpolator programmatically
mAnimation.setInterpolator( AnimationUtils.loadInterpolator(this,
android.R.anim.accelerate_interpolator));
Layout Animationnimatio
What is Layout Animation?
• Animations are applied when components are
laid out
> When components are added or removed from
layouts, these animations are triggered.
Steps for Layout Animation
1.Create “layout animation” resource files
under /res/anim/ directory
2.Add android:layoutAnimation=@anim/<layout-
animation-resource-file> attribute to the layout
3.Load the layout resource file as you normally
do
1. Create Animation XML Resources
• Create it under /res/anim/ directory - let's call it
/res/anim/layout_bottom_to_top_slide.xml
<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation
xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="500%"
android:animationOrder="reverse"
android:animation="@anim/slide_right" />
• The above uses /res/anim/slide_right.xml below
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="-100%p" android:toXDelta="0"
android:duration="@android:integer/config_shortAnimTime" />
</set>
2. Create Layout Resource File
• Layout resource file now has
android:layoutAnimation attribute
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutAnimation="@anim/layout_bottom_to_top_slide" />
3. Load Layout resource
• There is nothing different in this code
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_animation_3);
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, mStrings));
}
23
Thank you
hank you!

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Android intents
Android intentsAndroid intents
Android intents
 
Android Programming Basics
Android Programming BasicsAndroid Programming Basics
Android Programming Basics
 
Android Components
Android ComponentsAndroid Components
Android Components
 
android layouts
android layoutsandroid layouts
android layouts
 
Android activities & views
Android activities & viewsAndroid activities & views
Android activities & views
 
Android resource
Android resourceAndroid resource
Android resource
 
Android graphics
Android graphicsAndroid graphics
Android graphics
 
Action Bar in Android
Action Bar in AndroidAction Bar in Android
Action Bar in Android
 
Android share preferences
Android share preferencesAndroid share preferences
Android share preferences
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
Layouts in android
Layouts in androidLayouts in android
Layouts in android
 
Android App Development - 05 Action bar
Android App Development - 05 Action barAndroid App Development - 05 Action bar
Android App Development - 05 Action bar
 
Android: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast ReceiversAndroid: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast Receivers
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 
Android intent
Android intentAndroid intent
Android intent
 
Android adapters
Android adaptersAndroid adapters
Android adapters
 
[Android] Android Animation
[Android] Android Animation[Android] Android Animation
[Android] Android Animation
 
Events and Listeners in Android
Events and Listeners in AndroidEvents and Listeners in Android
Events and Listeners in Android
 
Intents in Android
Intents in AndroidIntents in Android
Intents in Android
 
Notification android
Notification androidNotification android
Notification android
 

Destaque

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
 
Basic Android Animation
Basic Android Animation Basic Android Animation
Basic Android Animation Shilu Shrestha
 
Android Transition
Android TransitionAndroid Transition
Android TransitionCharile Tsai
 
Android App Development - 12 animations
Android App Development - 12 animationsAndroid App Development - 12 animations
Android App Development - 12 animationsDiego Grancini
 
ppt based on android technology with great animations
ppt based on android technology with great animationsppt based on android technology with great animations
ppt based on android technology with great animationsHriday Garg
 
Android design and Custom views
Android design and Custom views Android design and Custom views
Android design and Custom views Lars Vogel
 
Material design for android
Material design for androidMaterial design for android
Material design for androidVmoksha Admin
 
School Management System in Android
School Management System in AndroidSchool Management System in Android
School Management System in AndroidTeam Codingparks
 
Android Material Design APIs/Tips
Android Material Design APIs/TipsAndroid Material Design APIs/Tips
Android Material Design APIs/TipsKen Yee
 
Material design - AndroidosDay 2015
Material design - AndroidosDay 2015Material design - AndroidosDay 2015
Material design - AndroidosDay 2015rlecheta
 
Material design basics
Material design basicsMaterial design basics
Material design basicsJorge Barroso
 
Esp chap 4 materials design (finished)
Esp chap 4   materials design (finished)Esp chap 4   materials design (finished)
Esp chap 4 materials design (finished)Nik Nor Nabillah Anis
 
Android tutorial ppt
Android tutorial pptAndroid tutorial ppt
Android tutorial pptRehna Renu
 

Destaque (19)

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)
 
Basic Android Animation
Basic Android Animation Basic Android Animation
Basic Android Animation
 
Android Transition
Android TransitionAndroid Transition
Android Transition
 
Android App Development - 12 animations
Android App Development - 12 animationsAndroid App Development - 12 animations
Android App Development - 12 animations
 
ppt based on android technology with great animations
ppt based on android technology with great animationsppt based on android technology with great animations
ppt based on android technology with great animations
 
Android design and Custom views
Android design and Custom views Android design and Custom views
Android design and Custom views
 
Android Animator
Android AnimatorAndroid Animator
Android Animator
 
Material design for android
Material design for androidMaterial design for android
Material design for android
 
School Management System in Android
School Management System in AndroidSchool Management System in Android
School Management System in Android
 
Android Material Design APIs/Tips
Android Material Design APIs/TipsAndroid Material Design APIs/Tips
Android Material Design APIs/Tips
 
Material design - AndroidosDay 2015
Material design - AndroidosDay 2015Material design - AndroidosDay 2015
Material design - AndroidosDay 2015
 
Android Material Design
Android Material DesignAndroid Material Design
Android Material Design
 
Material design basics
Material design basicsMaterial design basics
Material design basics
 
Materials design
Materials designMaterials design
Materials design
 
Esp chap 4 materials design (finished)
Esp chap 4   materials design (finished)Esp chap 4   materials design (finished)
Esp chap 4 materials design (finished)
 
Material Design Android
Material Design AndroidMaterial Design Android
Material Design Android
 
Android tutorial ppt
Android tutorial pptAndroid tutorial ppt
Android tutorial ppt
 

Semelhante a Android animation

Android RotateAnimation 簡介
Android RotateAnimation 簡介Android RotateAnimation 簡介
Android RotateAnimation 簡介Chun-Chia Chen
 
Android 2D Drawing and Animation Framework
Android 2D Drawing and Animation FrameworkAndroid 2D Drawing and Animation Framework
Android 2D Drawing and Animation FrameworkJussi Pohjolainen
 
Practical tipsmakemobilefaster oscon2016
Practical tipsmakemobilefaster oscon2016Practical tipsmakemobilefaster oscon2016
Practical tipsmakemobilefaster oscon2016Doris Chen
 
Practical Responsive Images - from Second Wednesday
Practical Responsive Images - from Second WednesdayPractical Responsive Images - from Second Wednesday
Practical Responsive Images - from Second WednesdayBen Seymour
 
Animate Me, if you don't do it for me do it for chet (DroidCon Paris)
Animate Me, if you don't do it for me do it for chet (DroidCon Paris)Animate Me, if you don't do it for me do it for chet (DroidCon Paris)
Animate Me, if you don't do it for me do it for chet (DroidCon Paris)Mathias Seguy
 
Building iPad apps with Flex - 360Flex
Building iPad apps with Flex - 360FlexBuilding iPad apps with Flex - 360Flex
Building iPad apps with Flex - 360Flexdanielwanja
 
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015Mathias Seguy
 
Basics and different xml files used in android
Basics and different xml files used in androidBasics and different xml files used in android
Basics and different xml files used in androidMahmudul Hasan
 
Google I/O 2011, Android Honeycomb Highlights
Google I/O 2011, Android Honeycomb HighlightsGoogle I/O 2011, Android Honeycomb Highlights
Google I/O 2011, Android Honeycomb HighlightsRomain Guy
 
Constraint-ly motion - making your app dance - John Hoford, Google
Constraint-ly motion - making your app dance - John Hoford, GoogleConstraint-ly motion - making your app dance - John Hoford, Google
Constraint-ly motion - making your app dance - John Hoford, GoogleDroidConTLV
 
Top 10 HTML5 features
Top 10 HTML5 featuresTop 10 HTML5 features
Top 10 HTML5 featuresGill Cleeren
 
ADF Mobile: 10 Things you don't get from the developers guide
ADF Mobile: 10 Things you don't get from the developers guideADF Mobile: 10 Things you don't get from the developers guide
ADF Mobile: 10 Things you don't get from the developers guideLuc Bors
 
Fernando F. Gallego - Efficient Android Resources 101
Fernando F. Gallego - Efficient Android Resources 101Fernando F. Gallego - Efficient Android Resources 101
Fernando F. Gallego - Efficient Android Resources 101Fernando Gallego
 
Introduction to A-Frame
Introduction to A-FrameIntroduction to A-Frame
Introduction to A-FrameDaosheng Mu
 

Semelhante a Android animation (20)

Day seven
Day sevenDay seven
Day seven
 
Android RotateAnimation 簡介
Android RotateAnimation 簡介Android RotateAnimation 簡介
Android RotateAnimation 簡介
 
Android view animation in android-chapter18
Android view animation in android-chapter18Android view animation in android-chapter18
Android view animation in android-chapter18
 
Android 2D Drawing and Animation Framework
Android 2D Drawing and Animation FrameworkAndroid 2D Drawing and Animation Framework
Android 2D Drawing and Animation Framework
 
Practical tipsmakemobilefaster oscon2016
Practical tipsmakemobilefaster oscon2016Practical tipsmakemobilefaster oscon2016
Practical tipsmakemobilefaster oscon2016
 
Practical Responsive Images - from Second Wednesday
Practical Responsive Images - from Second WednesdayPractical Responsive Images - from Second Wednesday
Practical Responsive Images - from Second Wednesday
 
Supercharge your ui
Supercharge your uiSupercharge your ui
Supercharge your ui
 
Animate Me, if you don't do it for me do it for chet (DroidCon Paris)
Animate Me, if you don't do it for me do it for chet (DroidCon Paris)Animate Me, if you don't do it for me do it for chet (DroidCon Paris)
Animate Me, if you don't do it for me do it for chet (DroidCon Paris)
 
Building iPad apps with Flex - 360Flex
Building iPad apps with Flex - 360FlexBuilding iPad apps with Flex - 360Flex
Building iPad apps with Flex - 360Flex
 
Layouts in android
Layouts in androidLayouts in android
Layouts in android
 
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015
 
Basics and different xml files used in android
Basics and different xml files used in androidBasics and different xml files used in android
Basics and different xml files used in android
 
Google I/O 2011, Android Honeycomb Highlights
Google I/O 2011, Android Honeycomb HighlightsGoogle I/O 2011, Android Honeycomb Highlights
Google I/O 2011, Android Honeycomb Highlights
 
Constraint-ly motion - making your app dance - John Hoford, Google
Constraint-ly motion - making your app dance - John Hoford, GoogleConstraint-ly motion - making your app dance - John Hoford, Google
Constraint-ly motion - making your app dance - John Hoford, Google
 
Top 10 HTML5 features
Top 10 HTML5 featuresTop 10 HTML5 features
Top 10 HTML5 features
 
ADF Mobile: 10 Things you don't get from the developers guide - Luc Bors
ADF Mobile: 10 Things you don't get from the developers guide - Luc BorsADF Mobile: 10 Things you don't get from the developers guide - Luc Bors
ADF Mobile: 10 Things you don't get from the developers guide - Luc Bors
 
ADF Mobile: 10 Things you don't get from the developers guide
ADF Mobile: 10 Things you don't get from the developers guideADF Mobile: 10 Things you don't get from the developers guide
ADF Mobile: 10 Things you don't get from the developers guide
 
Intro to appcelerator
Intro to appceleratorIntro to appcelerator
Intro to appcelerator
 
Fernando F. Gallego - Efficient Android Resources 101
Fernando F. Gallego - Efficient Android Resources 101Fernando F. Gallego - Efficient Android Resources 101
Fernando F. Gallego - Efficient Android Resources 101
 
Introduction to A-Frame
Introduction to A-FrameIntroduction to A-Frame
Introduction to A-Frame
 

Mais de Krazy Koder (20)

2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xc
2310 b xc2310 b xc
2310 b xc
 
2310 b xb
2310 b xb2310 b xb
2310 b xb
 
2310 b 17
2310 b 172310 b 17
2310 b 17
 
2310 b 16
2310 b 162310 b 16
2310 b 16
 
2310 b 16
2310 b 162310 b 16
2310 b 16
 
2310 b 15
2310 b 152310 b 15
2310 b 15
 
2310 b 15
2310 b 152310 b 15
2310 b 15
 
2310 b 14
2310 b 142310 b 14
2310 b 14
 
2310 b 13
2310 b 132310 b 13
2310 b 13
 
2310 b 12
2310 b 122310 b 12
2310 b 12
 
2310 b 11
2310 b 112310 b 11
2310 b 11
 
2310 b 10
2310 b 102310 b 10
2310 b 10
 
2310 b 09
2310 b 092310 b 09
2310 b 09
 
2310 b 08
2310 b 082310 b 08
2310 b 08
 
2310 b 08
2310 b 082310 b 08
2310 b 08
 
2310 b 08
2310 b 082310 b 08
2310 b 08
 
2310 b 07
2310 b 072310 b 07
2310 b 07
 

Último

Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...amitlee9823
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...lizamodels9
 
RSA Conference Exhibitor List 2024 - Exhibitors Data
RSA Conference Exhibitor List 2024 - Exhibitors DataRSA Conference Exhibitor List 2024 - Exhibitors Data
RSA Conference Exhibitor List 2024 - Exhibitors DataExhibitors Data
 
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...lizamodels9
 
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...rajveerescorts2022
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Dave Litwiller
 
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...allensay1
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesDipal Arora
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...lizamodels9
 
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceEluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceDamini Dixit
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876dlhescort
 
Falcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting
 
Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1kcpayne
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableSeo
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxAndy Lambert
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Serviceritikaroy0888
 
Phases of Negotiation .pptx
 Phases of Negotiation .pptx Phases of Negotiation .pptx
Phases of Negotiation .pptxnandhinijagan9867
 
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxpriyanshujha201
 

Último (20)

Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
 
RSA Conference Exhibitor List 2024 - Exhibitors Data
RSA Conference Exhibitor List 2024 - Exhibitors DataRSA Conference Exhibitor List 2024 - Exhibitors Data
RSA Conference Exhibitor List 2024 - Exhibitors Data
 
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
 
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
 
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
 
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceEluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
 
Falcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investors
 
Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptx
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Service
 
Phases of Negotiation .pptx
 Phases of Negotiation .pptx Phases of Negotiation .pptx
Phases of Negotiation .pptx
 
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
 
Falcon Invoice Discounting platform in india
Falcon Invoice Discounting platform in indiaFalcon Invoice Discounting platform in india
Falcon Invoice Discounting platform in india
 
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
 

Android animation

  • 2. Topics • Frame by Frame animation • Tween animation > Translate, Rotate, Scale, Alpha • Interpolator • Layout animation
  • 4. What is Frame-by-Frame Animation? • Created with a sequence of different images, played in order, like a roll of film. • Pieces > The frames in the /res/drawable directory > Animation resource XML file in which the frames are specified as <item> under <animation-list> > Code that loads the Animation resource XML file
  • 5. Animation XML Resource • The XML file consists of an <animation-list> element as the root node and a series of child <item> nodes that each define a frame <?xml version="1.0" encoding="UTF-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" id="selected" android:oneshot="false"> <item android:drawable="@drawable/ball1" android:duration="50" /> <item android:drawable="@drawable/ball2" android:duration="50" /> <item android:drawable="@drawable/ball3" android:duration="50" /> <item android:drawable="@drawable/ball4" android:duration="50" /> <item android:drawable="@drawable/ball5" android:duration="50" /> <item android:drawable="@drawable/ball6" android:duration="50" /> </animation-list>
  • 6. Code That Starts the Animation public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.framebyframe); // Load the ImageView that will host the animation and // set its background to the AnimationDrawable XML resource. ImageView img = (ImageView) findViewById(R.id.my_image_view); img.setBackgroundResource(R.anim.simple_animation); // Get the background, which has been compiled to an AnimationDrawable object. frameAnimation = (AnimationDrawable) img.getBackground(); } public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (animationStarted){ frameAnimation.stop(); animationStarted = false; } else{ frameAnimation.start(); animationStarted = true; } return true; } return super.onTouchEvent(event);
  • 8. Built-in Tween Animation Schemes • TransitionAnimation > Position change • RotateAnimation > Rotation • ScaleAnimation > Scaling • AlphaAnimation > Transparancy
  • 9. Steps of Tween Animation • Create XML animation resource file in /res/anim/ directory • Load the XML animation resource file into Animation object • Start the animation
  • 10. Create Animation XML Resource • The XML file is located under /res/anim/ directory • Example below is for Rotate animation <?xml version="1.0" encoding="UTF-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:fromDegrees="0" android:toDegrees="270" android:toYScale="0.0" android:pivotX="50%" android:pivotY="50%" android:startOffset="700" android:duration="700" />
  • 11. Create Animation XML Resource • Sequential animation is done with <set> • Example below - Translate animation followed by Rotate animation <set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false"> <translate android:fromXDelta="0" android:toXDelta="100" android:fromYDelta="0" android:toYDelta="150" android:duration="1000" /> <rotate android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:fromDegrees="0" android:toDegrees="270" android:toYScale="0.0" android:pivotX="50%" android:pivotY="50%" android:startOffset="700" android:duration="700" /> </set>
  • 12. Loading Animation Resource & Staring Animation // Load Animation object from a resource Animation rotate = AnimationUtils.loadAnimation(this, R.anim.rotate); // Select the animation target and start the animation findViewById(R.id.myimage).startAnimation(rotate);
  • 14. What is Interpolator • An interpolator defines the rate of change of an animation. • This allows the basic animation effects (alpha, scale, translate, rotate) to be accelerated, decelerated, repeated, etc. • You can set an interpolator either in XML animation resource file or programmatically
  • 15. Built-in Android Interpolators • Built-in Android Interpolators > android.R.anim.accelerate_interpolator > android.R.anim.decelerate_interpolator > android.R.anim.accelerate_decelerate_interpolator > android.R.anim.anticipate_interpolator > android.R.anim.overshoot_interpolator • Example of setting interpolator programmatically mAnimation.setInterpolator( AnimationUtils.loadInterpolator(this, android.R.anim.accelerate_interpolator));
  • 17. What is Layout Animation? • Animations are applied when components are laid out > When components are added or removed from layouts, these animations are triggered.
  • 18. Steps for Layout Animation 1.Create “layout animation” resource files under /res/anim/ directory 2.Add android:layoutAnimation=@anim/<layout- animation-resource-file> attribute to the layout 3.Load the layout resource file as you normally do
  • 19. 1. Create Animation XML Resources • Create it under /res/anim/ directory - let's call it /res/anim/layout_bottom_to_top_slide.xml <?xml version="1.0" encoding="utf-8"?> <layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" android:delay="500%" android:animationOrder="reverse" android:animation="@anim/slide_right" /> • The above uses /res/anim/slide_right.xml below <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <translate android:fromXDelta="-100%p" android:toXDelta="0" android:duration="@android:integer/config_shortAnimTime" /> </set>
  • 20. 2. Create Layout Resource File • Layout resource file now has android:layoutAnimation attribute <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="match_parent" android:layoutAnimation="@anim/layout_bottom_to_top_slide" />
  • 21. 3. Load Layout resource • There is nothing different in this code public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_animation_3); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mStrings)); }