Android 3.0 Animations: Beginner’s Guide


Android 3.0 Animations: Beginner’s Guide
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
$22.94
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
$44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • The first and only book dedicated to creating animations for Android apps.
  • Covers all of the commonly used animation techniques for Android 3.0 and lower versions.
  • Create stunning animations to give your Android apps a fun and intuitive user experience.
  • A step-by-step guide for learning animation by building fun example applications and games.

Book Details

Language : English
Paperback : 304 pages [ 235mm x 191mm ]
Release Date : November 2011
ISBN : 184951528X
ISBN 13 : 9781849515283
Author(s) : Alex Shaw
Topics and Technologies : All Books, Mobile Application Development, Android, Beginner's Guides

Table of Contents

Preface
Chapter 1: Animation Techniques on Android
Chapter 2: Frame Animations
Chapter 3: Tweening and Using Animators
Chapter 4: Animating Properties and Tweening Pages
Chapter 5: Creating Classes for Tween Animation
Chapter 6: Using 3D Visual Techniques
Chapter 7: 2D Graphics with Surfaces
Chapter 8: Live Wallpapers
Chapter 9: Practicing Good Practice and Style
Appendix: Pop Quiz Answers
Index
  • Chapter 1: Animation Techniques on Android
    • An animated application: counting calculator
    • Time for action – learning to count with the counting calculator
    • Frame animation
    • Time for action – playing with the frames
      • Fancy frame animations
      • Simple fades using transition animations
    • Tweening
    • Time for action – finding tweens
      • The tween jazz band
      • Interpolations—meet the drummer
      • Animation sets—meet the conductor
      • Tweening elements in XML
      • What are tweens good at?
    • Animators – new in Android 3.0!
    • Beyond views: high-speed animating in 2 dimensions
      • Drawing loops
      • Doing your own housekeeping is hard
      • Where to use surfaces
    • What do views do anyway?
    • Time for action – let's draw views
    • Animating awesome 3D
      • Want to go faster?
    • Making a better application
      • Always be helpful
      • Small and powered by batteries
    • Summary
    • Chapter 2: Frame Animations
      • Making a frame animation
      • Time for action – the funky stick man
        • The anatomy of a frame animation
        • XML elements
          • <animation-list>
          • <item>
        • Timing
        • Images and Drawables
        • Screen size
        • Sometimes you run out of memory
      • Making frame animations in Java
      • Time for action – making the stick man interactive
        • Controlling frame animations
          • start() and stop()
          • AnimationDrawable.setVisible(true,true)
        • Creating new animations
      • Time for action – programmatically defined animation
        • More neat methods on AnimationDrawable
        • Working properly in the GUI thread
    • Animating a transition between frames
    • Time for action – make the transition
      • Writing XML for a transitionDrawable
        • <transition>
        • <item>
      • Working with other useful methods
        • startTransition(int duration)
        • reverseTransition(int duration)
        • resetTransition()
    • Summary
      • Chapter 3: Tweening and Using Animators
        • Greeting the tween
        • Time for action – making a tower of Hanoi puzzle
          • Defining starts and ends
        • Assembling the building blocks of a tween
        • Time for action – composing a tween animation
          • Taking a look at the different types of tween animation
            • <translate>
            • <rotate>
            • <alpha>
            • <scale>
            • Common attributes
          • Declaring tweens in the correct order
          • Making tweens that last for ever
        • Time for action – creating an everlasting tween
          • Animating layouts
        • Time for action – laying out blocks
        • Receiving animation events
        • Time for action – receiving animation events
        • Interpolating animations
        • Time for action – changing the rhythm with interpolators
          • Using the interpolators provided by Android
            • Linear interpolator
            • Accelerate interpolator
            • Decelerate interpolator
            • Accelerate-decelerate interpolator
            • Bounce interpolator
            • Anticipate interpolator
            • Overshoot interpolator
            • Anticipate overshoot interpolator
            • Cycle interpolator
          • Sharing interpolators
            • android:sharedInterpolator="true"
            • android:sharedInterpolator="false"
          • Creating and parameterizing interpolators
        • Finding out more
        • Summary
        • Chapter 4: Animating Properties and Tweening Pages
          • Note for developers using versions of Android before 3.0
          • Turning pages with a ViewFlipper
          • Time for action – making an interactive book
          • Creating tween animations in Java
          • Time for action – creating a tween in Java
          • Writing the SlideAndScale animation in Java
            • Writing the SlideAndScale animation In XML
            • Animating with ObjectAnimator
          • Time for action – animating the rolling ball
            • Constructing ObjectAnimators
              • Breaking down the construction of ballRoller
            • Getting and setting with ObjectAnimators
          • Animating values with ValueAnimator
          • Time for action – making a ball bounce
            • Updating the frame rate
            • Changing the interpolator
          • Time for action – improving our bouncing ball
          • Comparing animators and tweens
            • Advantages of animators
            • Advantages of tweens
            • Things that are common between animators and tweens
          • Summary
          • Chapter 5: Creating Classes for Tween Animation
            • Creating multi-variable Animators
            • Time for action – making an animated Orrery
              • The structure of the Orrery
              • Animating LayerDrawables
              • PropertyValuesHolder
              • Helpful ValueAnimator parameters
              • Using objects as parameters for value animations
            • Time for action – animating between objects
              • Using a TypeEvaluator
              • Setting Keyframes
            • Time for action – defining fixed points with Keyframes
              • Using the Keyframe
              • Keyframe timing
              • Combining Fragments and XML Animators
            • Time for action – adding a Description Pane
              • Declaring ObjectAnimator attributes
            • Customizing the interpolator classes
              • What do interpolators do?
            • Time for action – making a teleport interpolator
              • Interpolator value ranges
            • Summary
            • Chapter 6: Using 3D Visual Techniques
              • Understanding 3D graphics
              • Showing depth with 3D effects
              • Raising elements
              • Time for action – making a jigsaw with lifting pieces
                • Laying out the jigsaw
                • Special classes we created to help animation
                  • Scaling the image with ScalableImageView.SetDepth
                • Moving pieces with PieceSwapper
                  • Completing the animation with PieceSwapper.onAnimationEnd
                • Adding drop shadows
              • Time for action – using shadows with our jigsaw
                • Conjuring up a change in focus
              • Time for action – changing the focus of the jigsaw
                • Setting the image focus on a RaisableImageView
                • Applying image focus to the whole jigsaw
              • Creating 3D rotations
              • Time for action – spinning jigsaws
                • Examining Rotate3DAnimation.java
                • Extending a tween animation
                  • initialize (int width, int height, int parentWidth, int parentHeight)
                  • applyTransformation (float interpolatedTime, Transformation t)
                • Describing transformations with a Matrix (android.graphics.Matrix)
                • Doing 3D transformations with a Camera (android.graphics.Camera)
                  • rotateX (float), rotateY (float), rotateZ (float)
                  • translate (float x, float y, float z)
                  • save() and restore()
              • Summary
              • Chapter 7: 2D Graphics with Surfaces
                • Introducing game loops
                • Drawing a surface on the screen
                • Time for action – animating bubbles on a surface
                  • The design of the Bubbles application
                    • Investigating Bubble.java
                    • Investigating BubblesView.java
                  • Seeing the game loop in action
                  • Using a SurfaceView
                  • Using a SurfaceHolder
                    • lockCanvas
                    • unlockCanvasAndPost
                  • Using a SurfaceHolder.Callback
                    • surfaceCreated (SurfaceHolder holder)
                    • surfaceDestroyed(SurfaceHolder holder)
                    • surfaceChanged(SurfaceHolder holder, int format, int width, int height)
                  • Using the Canvas as an animation tool
                • Time for action – making more realistic bubbles
                  • Getting to know the drawing tools in Canvas
                    • drawBitmap and drawPicture
                    • drawCircle
                    • drawColor and drawPaint
                    • drawLine and drawLines
                    • drawOval and drawArc
                    • drawPath
                    • drawRect and drawRoundRect
                    • drawText and drawTextOnPath
                  • Using Paint effects
                    • setAlpha
                    • setAntiAlias
                    • setColor
                    • setStrokeCap
                    • setStrokeWidth
                    • setStyle
                    • setTextAlign
                    • setTextScaleX
                    • setTextSize
                    • setTypeface
                  • Frame scheduling
                • Time for action – creating smooth game loops
                  • Adjusting the frame duration
                  • Taking the wait out of the game loop
                • Summary
                • Chapter 8: Live Wallpapers
                  • Creating a live wallpaper
                  • Time for action – making our first live wallpaper
                    • Declaring a live wallpaper
                    • How live wallpapers appear
                    • Understanding services
                      • WallpaperService
                  • Adding interactivity to live wallpaper
                  • Time for action – making soapy fingers
                    • Enabling WallpaperService.Engine interaction
                    • Registering live wallpaper interaction
                  • Using live wallpaper preferences
                  • Time for action – configuring a live wallpaper
                    • Updating preferences as soon as they are set
                  • Time for action – updating live wallpaper configuration
                    • Connecting our wallpaper to our prefereces
                    • Disconnecting our preferences when our wallpaper exits
                  • How the user will see preferences
                  • Storing preferences with SharedPreferences
                    • Reading from SharedPreferences
                    • Writing to SharedPreferences
                    • OnSharedPreferenceChangedListener
                  • Composing preference XML
                    • Defining preferences in XML
                    • Setting attributes on XML preferences
                • Summary
                  • Chapter 9: Practicing Good Practice and Style
                    • Using focus and metaphor
                      • Looking at focus
                    • Time for action – don't confuse me with animation!
                      • Getting to grips with metaphors
                    • Time for action – getting messages from houses
                      • Focus, redux
                      • Maintaining consistency within an application
                    • Reducing power usage
                    • Time for action – measuring battery usage with PowerTutor
                      • Precise estimation
                      • Changing the Application Viewer Timespan
                      • PowerTutor-supported devices
                      • Optimizing an animation for power
                      • Looking for problems
                    • Time for action – identifying a problem
                      • Finding the power hogs
                    • Time for action – tracing to find optimizations
                      • Removing the gremlin
                    • Time for action – squashing gremlins that use too much power
                      • Optimizing using an easy recipe
                    • Summary
                    • Appendix: Pop Quiz Answers
                      • Chapter 1: Animation Techniques on Android
                        • View animations and Drawable animations
                        • Putting it all together
                      • Chapter 2: Frame Animations
                        • Making frame animations
                        • Controlling frame animations
                        • Transition Drawables
                      • Chapter 3: Tweening and Using Animators
                        • All those tweens!
                        • AnimationListeners
                        • Interpolators
                      • Chapter 4: Animating Properties and Tweening Pages
                        • ViewFlippers
                        • Java tweens
                        • ObjectAnimators
                        • Value Animators
                      • Chapter 5: Creating Classes for Tween Animation
                        • PropertyValueHolders, ObjectAnimators, and TypeEvaluators
                        • Fragment Animation and XML Animators
                        • Custom interpolators
                      • Chapter 6: Using 3D Visual Techniques
                        • Depth effects
                        • 3D rotations
                      • Chapter 7: 2D Graphics with Surfaces
                        • Surface animations
                      • Chapter 8: Live Wallpapers
                        • Live wallpapers
                        • Interactivity
                        • Preferences for live wallpapers
                      • Chapter 9: Practicing Good Practice and Style
                        • Usability
                        • Power usage

                      Alex Shaw

                      Alex Shaw has been developing on Android since 2008 and has never looked back. He created one of the first music-writing applications for the platform, and has worked on Android with business, academia, and the open-source community. He has presented papers on Android development at events across Europe. Alex lives in Edinburgh where it rains a lot and mobile development is a welcome escape from the weather.
                      Sorry, we don't have any reviews for this title yet.

                      Code Downloads

                      Download the code and support files for this book.


                      Submit Errata

                      Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                      Errata

                      - 1 submitted: last submission 02 Aug 2012

                      Errata type: code | Page number: Chapter 8, Time for action - making our first live wallpaper | Errata date: 07/26/2012

                      there are two steps that need attention.
                      step 5. Should read (changes highlighted in bold):
                      Now we need to actually define our service. You will recall from step 2 that we named it BubblesWallpaperService, so create a new Java file called BubblesWallpaperService.java in the package com.packt.animation.bubbleswallpaper . In it, we will add the following import definitions: ---etc---
                      step 7. This step makes it clear that the files should be copied to the src/com/packt/animation/bubbleswallpaper directory, so no erratum is required here but please let your reader know that they need to move their java classes currently in "(default package)" to "com.packt.animation.bubbleswallpaper." This can be done with a simple drag and drop in Eclipse.

                      Sample chapters

                      You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                      Frequently bought together

                      Android 3.0 Animations: Beginner’s Guide +    Android NDK Beginner’s Guide =
                      50% Off
                      the second eBook
                      Price for both: £24.65

                      Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                      What you will learn from this book

                      • Create animated graphics from a set of still images
                      • Fade between graphical elements
                      • Move, distort, and generally mess around with parts of your user interface
                      • Create Dazzling 3D motion with a few simple principles
                      • Strip back the Android user interface to create fast animated graphics on the fly
                      • Experience striking results by changing your animation’s rhythm
                      • Create a live wallpaper to bring motion to your home-screen
                      • Design your animations to look great and work well on different Android devices

                      In Detail

                      An enjoyable, understandable, and eye-catching user interface is a key part of getting users to love your app. Users today expect a polished multimedia experience on their mobile device, and animation is a core part of that. The Android operating system is at the forefront of tablet and smartphone technology, and there is a plethora of opportunities for developing exciting applications with animation.

                      Android 3.0 Animations Beginner’s Guide will introduce each of the most popular animation techniques to you. Using step-by-step instructions, you will learn how to create interactive dynamic forms, moving graphics, and 3D motion.

                      You will be taken on a journey from simple stop motion animations and fades, through to moving input forms, then on to 3D motion and game graphics.

                      In this book, you will create standalone animated graphics, three-dimensional lifts, fades, and spins. You will become adept at moving and transforming form data to bring boring old input forms and displays to life. Learn how game programmers create fast animations on the fly, and also build live wallpapers to liven up your users’ home-screens!

                      If you are tired of writing lifeless interfaces and want to add some animated excitement, this is the book for you!

                      A step-by step guide for creating, testing, and making use of stunning animations for android applications and games.

                      Approach

                      Written in Packt’s Beginner’s Guide series, this book takes a step-by-step approach with each chapter made up of three to five tutorials that introduce and explain different animation concepts. All concepts are explained with real-world examples that are fun to read and work with.

                      Who this book is for

                      If you are familiar with developing Android applications and want to bring your apps to life by adding smashing animations, then this book is for you. The book assumes that you are comfortable with Java development and have familiarity with creating Android Views in XML and Java. The tutorials assume that you will want to work with Eclipse, but you can work just as well with your preferred development tools.

                      Code Download and Errata
                      Packt Anytime, Anywhere
                      Register Books
                      Print Upgrades
                      eBook Downloads
                      Video Support
                      Contact Us
                      Awards Voting Nominations Previous Winners
                      Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                      Resources
                      Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software