android 3.0 animations(2011)

304 365 0
android 3.0 animations(2011)

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Android 3.0 Animations Beginner's Guide Bring your Android applicaons to life with stunning animaons Alex Shaw BIRMINGHAM - MUMBAI D ownload from Wow! eBook <www.woweb o o k . c o m > Android 3.0 Animations Beginner's Guide Copyright © 2011 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmied in any form or by any means, without the prior wrien permission of the publisher, except in the case of brief quotaons embedded in crical arcles or reviews. Every eort has been made in the preparaon of this book to ensure the accuracy of the informaon presented. However, the informaon contained in this book is sold without warranty, either express or implied. Neither the author , nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark informaon about all of the companies and products menoned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this informaon. First published: October 2011 Producon Reference: 1211011 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-84951-528-3 www.packtpub.com Cover Image by Vinayak Chiar ( vinayak.chittar@gmail.com ) Credits Author Alex Shaw Reviewers Nathan Schwermann Roger Belk Acquision Editor Tarun Singh Development Editors Pallavi Iyengar Meeta Rajani Technical Editors Lubna Shaikh Ankita Shashi Copy Editor Leonard D'Silva Project Coordinator Shubhanjan Chaerjee Proofreaders Stephen Silk Samantha Lyon Indexer Monica Ajmera Graphics Geetanjali Sawant Producon Coordinator Melwyn D'sa Cover Work Melwyn D'sa About the Author Alex Shaw has been an Android fan boy since Android 1.5 arrived, and he began developing soware for it almost immediately. He has presented at DroidCon in Berlin and London, and wrien applicaons for business, academia, and pleasure. An alumnus of The University of Edinburgh, he has kept close business and social es with the Scosh geek scene. His consulng company, Glastonbridge Soware Limited, provides development resources to the Edinburgh soware industry. In his spare me, he writes generave music applicaons and talks a lot of nonsense. Hearty thanks to my partner, Amy Worthington, for pung up with my constant stream of ideas whenever wring was on my mind. Thanks also to my Mum and to my close friends, who have supported me when stress and anxiety were taking their toll. Thanks also to the team at Packt, who put up with my errac e-mail discipline and occasional late submissions, with paence and kindness. This book has been an adventure and an experience to remember. About the Reviewers Nathan Schwermann is a husband and proud father. He aends the University of Kansas to study Computer Science. In the past years, Nathan has worked as a freelance Android developer, making many great applicaons to help pay his high tuion costs. Nathan aspires to work for an independent gaming studio. Roger Belk , also known as Big Daddy App, has developed Android applicaons for the last year. He is a self taught 43-year-old Ironworker. He builds applicaons using Eclipse with Android SDK, Java, and Google's App Inventor. You can check out his website at www.BigDaddyApp.com Roger is also a power user in Google's App Inventor forums, answering help requests from new AI developers, from the setup, to the How-To, and to the coee shop just chang and kicking around ideals for AI apps. Books that he has worked on include Animaon 3.0 and Google App Inventor. www.PacktPub.com Support les, eBooks, discount offers and more You might want to visit www.PacktPub.com for support les and downloads related to your book. Did you know that Packt oers eBook versions of every book published, with PDF and ePub les available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com , you can also read a collecon of free technical arcles, sign up for a range of free newsleers and receive exclusive discounts and oers on Packt books and eBooks. http://PacktLib.PacktPub.com Do you need instant soluons to your IT quesons? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's enre library of books. Why Subscribe?  Fully searchable across every book published by Packt  Copy and paste, print and bookmark content  On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com , you can use this to access PacktLib today and view nine enrely free books. Simply use your login credenals for immediate access. Table of Contents Preface 1 Chapter 1: Animaon Techniques on Android 7 An animated applicaon: counng calculator 8 Time for acon – learning to count with the counng calculator 8 Frame animaon 10 Time for acon – playing with the frames 11 Fancy frame animaons 13 Simple fades using transion animaons 14 Tweening 14 Time for acon – nding tweens 15 The tween jazz band 15 Interpolaons—meet the drummer 16 Animaon sets—meet the conductor 16 Tweening elements in XML 16 What are tweens good at? 17 Animators – new in Android 3.0! 17 Beyond views: high-speed animang in 2 dimensions 19 Drawing loops 19 Doing your own housekeeping is hard 20 Where to use surfaces 21 What do views do anyway? 21 Time for acon – let's draw views 21 Animang awesome 3D 27 Want to go faster? 28 Making a beer applicaon 30 Always be helpful 30 Small and powered by baeries 30 Summary 32 Table of Contents [ ii ] Chapter 2: Frame Animaons 33 Making a frame animaon 34 Time for acon – the funky sck man 34 The anatomy of a frame animaon 38 XML elements 38 <animaon-list> 39 <item> 39 Timing 40 Images and Drawables 40 Screen size 41 Somemes you run out of memory 41 Making frame animaons in Java 43 Time for acon – making the sck man interacve 43 Controlling frame animaons 48 start() and stop() 48 AnimaonDrawable.setVisible(true,true) 48 Creang new animaons 48 Time for acon – programmacally dened animaon 48 More neat methods on AnimaonDrawable 52 Working properly in the GUI thread 53 Animang a transion between frames 55 Time for acon – make the transion 55 Wring XML for a transionDrawable 59 <transion> 59 <item> 59 Working with other useful methods 60 startTransion(int duraon) 60 reverseTransion(int duraon) 60 resetTransion() 60 Summary 62 Chapter 3: Tweening and Using Animators 63 Greeng the tween 63 Time for acon – making a tower of Hanoi puzzle 64 Dening starts and ends 67 Assembling the building blocks of a tween 68 Time for acon – composing a tween animaon 68 Taking a look at the dierent types of tween animaon 74 <translate> 74 <rotate> 74 <alpha> 75 <scale> 75 Common aributes 76 Declaring tweens in the correct order 76 Table of Contents [ iii ] Making tweens that last for ever 77 Time for acon – creang an everlasng tween 77 Animang layouts 81 Time for acon – laying out blocks 81 Receiving animaon events 83 Time for acon – receiving animaon events 84 Interpolang animaons 86 Time for acon – changing the rhythm with interpolators 86 Using the interpolators provided by Android 88 Linear interpolator 88 Accelerate interpolator 88 Decelerate interpolator 88 Accelerate-decelerate interpolator 88 Bounce interpolator 89 Ancipate interpolator 89 Overshoot interpolator 89 Ancipate overshoot interpolator 89 Cycle interpolator 89 Sharing interpolators 89 android:sharedInterpolator="true" 90 android:sharedInterpolator="false" 90 Creang and parameterizing interpolators 90 Finding out more 91 Summary 92 Chapter 4: Animang Properes and Tweening Pages 93 Note for developers using versions of Android before 3.0 94 Turning pages with a ViewFlipper 94 Time for acon – making an interacve book 94 Creang tween animaons in Java 103 Time for acon – creang a tween in Java 104 Wring the SlideAndScale animaon in Java 107 Wring the SlideAndScale animaon In XML 107 Animang with ObjectAnimator 108 Time for acon – animang the rolling ball 109 Construcng ObjectAnimators 111 Breaking down the construcon of ballRoller 111 Geng and seng with ObjectAnimators 112 Animang values with ValueAnimator 113 Time for acon – making a ball bounce 113 Updang the frame rate 117 Changing the interpolator 117 Time for acon – improving our bouncing ball 117 Comparing animators and tweens 119 . Animang awesome 3D 27 Want to go faster? 28 Making a beer applicaon 30 Always be helpful 30 Small and powered by baeries 30 Summary 32 Table of Contents. 206 setStyle 206 setTextAlign 207 setTextScaleX 207 setTextSize 207 setTypeface 207 Frame scheduling 207 Time for acon – creang smooth game loops 207

Ngày đăng: 10/12/2013, 17:35

Tài liệu cùng người dùng

Tài liệu liên quan