Upload
charile-tsai
View
705
Download
0
Embed Size (px)
Citation preview
Android TransitionCharlie@Android Taipei
Charlie Tsai@Android Study [email protected]
Individual App Developer &System Software Engineer@NVIDIA
Today’s source codehttps://github.com/chatea/TransitionDemo
Agenda
• Overview of Animations in Android• Transitions Framework• Demo and Live Coding
Animations in Android• Animation (API 1+)
• Animator (API 11+)• LayoutTransition (API 11+)• FragmentManager.beginTransaction() (support.v4 or API
11+) .setCustomAnimations(…) .add(…) / replace(…) .commit()
• ViewPropertyAnimator (API 12+)View.animate().setXXX(…).setYYY(…)
• Transitions Framework (API 19+)Scene, Transition, and TransitionManager
• Transition between Activities (API 21+)ActivityOptions.makeSceneTransitionAnimation(…)
API 19 are supported by ~80% devices
Transitions framework
Overview• Limitation• Scene• Transition• TransitionManager• Transition between Activities
Limitation
• Cannot be applied to the SurfaceView• Cannot be applied to the AdapterView
e.g. ListView(Use LayoutTransition instead)
• Resizing the TextView has some problems
Scene• Layout description between 2 scenes• Can be created from layout file
(res/layout/*.xml)• Can be created from code• Supports Callback:
Scene.setExitAction(Runnable) Scene.setEnterAction(Runnable)
Transitions• Used to indicated the animation• Built-in transitions: fading, resizing, etc.• Can be created from xml (res/transition/*.xml)• Can be created from code• Transition.TransitionListener• Transition.addTarget() & Transition.removeTarget()• Multiple Transitions: TransitionSet
Customized Transition
• public void captureStartValues(TransitionValues)
• public void captureEndValues(TransitionValues)
• public Animator createAnimator( ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues)
Customized Transition
• A data structure used to store customized animation properties.
• class TransitionValues { public Map<String, Object> values; public View view;}
TransitionManager• TransitionManager.go(Scene)
TransitionManager.go(Scene, Transition)• Transition.setTransition(…)
TransitionManager.transitionTo(Scene)• Animation without Scene and Transition
TransitionManager.beginDelayedTransition()
• Can be created by XML
Transition between Activities
• Enter & ExitFade, Explode, SlidegetWindow().setEnterTransition(…)getWindow().setExitTransition(…)
• Shared elementschangeBounds, changeClipBounds,changeTransform, changeImageTransform
• ActivityOptionsCompat.makeSceneTransitionAnimation()ViewCompat.setTransitionName(…)Window.getSharedElementEnterTransition()
Live coding
Official Samples
cmd + shift + a
固定聚會:每週三@菓子咖啡 (近捷運南京復興站 )技術分享:每月底週六 14:30 - 17:30
Question?
Thanks!