|
| 1 | +# Motion Layout Integrations samples |
| 2 | + |
| 3 | +This sample showcases realistic animations built using `MotionLayout` in |
| 4 | +real-world settings. |
| 5 | + |
| 6 | +It is recomended that you use Android Studio 4.0 or higher to view this sample |
| 7 | +to explore the animations in Motion Editor. For optimal experience, use Android |
| 8 | +Studio 4.2 or higher. |
| 9 | + |
| 10 | +## ViewPagerIntegration |
| 11 | +Integrate with `ViewPager` to create a dynamic header that animates as the user |
| 12 | +swipes. |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +This screen shows how to use a swipe event in another view to drive seekable |
| 17 | +animations in MotionLayout. It has a relatively simple animation, containing |
| 18 | +only two views, but by coordinating motion with user input it makes the screen |
| 19 | +engaging without adding a lot of code. |
| 20 | + |
| 21 | +| File | Content | |
| 22 | +| ----------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | |
| 23 | +| [Activity](src/main/java/com/example/androidstudio/motionlayoutintegrations/ViewPagerIntegration.kt) | Activity showing how to coordinate MotionLayout with ViewPager | |
| 24 | +| [layout](src/main/res/layout/activity_view_pager_integration.xml) | Layout with ViewPager and a MotionLayout | |
| 25 | +| [scene](src/main/res/xml/activity_view_pager_integration_scene.xml) | Scene to describe the animation with two states | |
| 26 | + |
| 27 | +## Entrance |
| 28 | + |
| 29 | +Build an entrance animation to play when the user enters a screen. |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +This example shows how to use `motion:autoTransition="animateToEnd"` to |
| 34 | +automatically progress animations through states. Visually it appears to be |
| 35 | +a single animation, but in code it's broken into four animations. For |
| 36 | +animations that play for a long time like this one, this can help break the |
| 37 | +animation into smaller pieces when developing. When viewed and edited in |
| 38 | +Motion Editor this structure makes it easier to work on just one part of the |
| 39 | +animation. |
| 40 | + |
| 41 | + |
| 42 | +> Animation is created by chaining multiple ConstraintSets |
| 43 | +
|
| 44 | +| File | Content | |
| 45 | +| ----------------------------------------------------------------------------------------- | -------------------------------------------------------------- | |
| 46 | +| [Activity](src/main/java/com/example/androidstudio/motionlayoutintegrations/Entrance.kt) | Regular Activity (no extra code) | |
| 47 | +| [layout](src/main/res/layout/activity_entrance.xml) | Layout all Views used in this animation | |
| 48 | +| [scene](src/main/res/xml/activity_entrance_sceen.xml) | Scene containing multiple ConstraintSet and Transition | |
| 49 | + |
| 50 | +## CollapsingToolbar |
| 51 | +Build a collapsing toolbar with support for insets using MotionLayout. |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +This example shows a complex custom collapsing toolbar built using |
| 56 | +MotionLayout. It shows how to use insets to set guidelines in a MotionLayout |
| 57 | +to avoid drawing under cutouts and display an animated systembar underlay. |
| 58 | + |
| 59 | +It also shows how to integrate MotionLayout with a custom view which draws the |
| 60 | +circular coutouts and animates the background. |
| 61 | + |
| 62 | +| File | Content | |
| 63 | +| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | |
| 64 | +| [Activity](src/main/java/com/example/androidstudio/motionlayoutintegrations/CollapsingToolbar.kt) | Integrate MotionLayout, CoordanatorLayout, and Custom View, and Insets | |
| 65 | +| [layout](src/main/res/layout/activity_collapsing_toolbar.xml) | Layout all Views used in this animation, including inset guidelines & custom view | |
| 66 | +| [scene](src/main/res/xml/activity_collapsing_toolbar_sceen.xml) | Scene showing how to integrate with custom views using CustomAttribute | |
0 commit comments