Trevor Johns | e904b62 | 2014-08-27 18:30:35 -0700 | [diff] [blame] | 1 | |
Trevor Johns | 89d2da0 | 2015-08-13 18:28:15 -0700 | [diff] [blame] | 2 | Android CustomTransition Sample |
| 3 | =================================== |
| 4 | |
| 5 | This sample shows how to implement a custom Transition extending the |
| 6 | standard Transition class. |
| 7 | |
| 8 | Introduction |
| 9 | ------------ |
| 10 | |
| 11 | In order to create a custom Transition, you first need to override |
| 12 | [captureStartValues][1] and [captureEndValues][2]. In those method, you have to |
| 13 | extract all the relevant properties from a View. These methods are called for |
| 14 | each of the Views in the hierarchy. |
| 15 | |
| 16 | Then, you need to override [createAnimator][3] and create an Animator based on |
| 17 | the property values you extracted. This method will also be called for each of |
| 18 | the Views in the hierarchy. If you want to skip some Views, simply return null. |
| 19 | |
| 20 | The instantiated custom Transition can be applied by passing it as the second |
| 21 | parameter of [TransitionManager.go][4]. |
| 22 | |
| 23 | ```java |
| 24 | TransitionManager.go(mScenes[mCurrentScene], mTransition); |
| 25 | ``` |
| 26 | |
| 27 | [1]: https://developer.android.com/reference/android/transition/Transition.html#captureStartValues(android.transition.TransitionValues) |
| 28 | [2]: https://developer.android.com/reference/android/transition/Transition.html#captureEndValues(android.transition.TransitionValues) |
| 29 | [3]: https://developer.android.com/reference/android/transition/Transition.html#createAnimator(android.view.ViewGroup, android.transition.TransitionValues, android.transition.TransitionValues) |
| 30 | [4]: https://developer.android.com/reference/android/transition/TransitionManager.html#go(android.transition.Scene, android.transition.Transition) |
Trevor Johns | e904b62 | 2014-08-27 18:30:35 -0700 | [diff] [blame] | 31 | |
| 32 | Pre-requisites |
| 33 | -------------- |
| 34 | |
Trevor Johns | fc1c2ea | 2016-08-11 15:43:37 -0700 | [diff] [blame] | 35 | - Android SDK 24 |
| 36 | - Android Build Tools v24.0.1 |
Trevor Johns | e904b62 | 2014-08-27 18:30:35 -0700 | [diff] [blame] | 37 | - Android Support Repository |
| 38 | |
Trevor Johns | 89d2da0 | 2015-08-13 18:28:15 -0700 | [diff] [blame] | 39 | Screenshots |
| 40 | ------------- |
| 41 | |
| 42 | <img src="screenshots/main.png" height="400" alt="Screenshot"/> |
| 43 | |
Trevor Johns | e904b62 | 2014-08-27 18:30:35 -0700 | [diff] [blame] | 44 | Getting Started |
| 45 | --------------- |
| 46 | |
| 47 | This sample uses the Gradle build system. To build this project, use the |
| 48 | "gradlew build" command or use "Import Project" in Android Studio. |
| 49 | |
| 50 | Support |
| 51 | ------- |
| 52 | |
| 53 | - Google+ Community: https://plus.google.com/communities/105153134372062985968 |
| 54 | - Stack Overflow: http://stackoverflow.com/questions/tagged/android |
| 55 | |
| 56 | If you've found an error in this sample, please file an issue: |
| 57 | https://github.com/googlesamples/android-CustomTransition |
| 58 | |
| 59 | Patches are encouraged, and may be submitted by forking this project and |
| 60 | submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details. |
| 61 | |
| 62 | License |
| 63 | ------- |
| 64 | |
Trevor Johns | fc1c2ea | 2016-08-11 15:43:37 -0700 | [diff] [blame] | 65 | Copyright 2016 The Android Open Source Project, Inc. |
Trevor Johns | e904b62 | 2014-08-27 18:30:35 -0700 | [diff] [blame] | 66 | |
| 67 | Licensed to the Apache Software Foundation (ASF) under one or more contributor |
| 68 | license agreements. See the NOTICE file distributed with this work for |
| 69 | additional information regarding copyright ownership. The ASF licenses this |
| 70 | file to you under the Apache License, Version 2.0 (the "License"); you may not |
| 71 | use this file except in compliance with the License. You may obtain a copy of |
| 72 | the License at |
| 73 | |
Trevor Johns | 89d2da0 | 2015-08-13 18:28:15 -0700 | [diff] [blame] | 74 | http://www.apache.org/licenses/LICENSE-2.0 |
Trevor Johns | e904b62 | 2014-08-27 18:30:35 -0700 | [diff] [blame] | 75 | |
| 76 | Unless required by applicable law or agreed to in writing, software |
| 77 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 78 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 79 | License for the specific language governing permissions and limitations under |
| 80 | the License. |