开源软件名称(OpenSource Name):willowtreeapps/spruce-android开源软件地址(OpenSource Url):https://github.com/willowtreeapps/spruce-android开源编程语言(OpenSource Language):Java 95.9%开源软件介绍(OpenSource Introduction):iOS)Spruce Android Animation Library (andWhat is it?Spruce is a lightweight animation library that helps choreograph the animations on the screen. With so many different animation libraries out there, developers need to make sure that each view is animating at the appropriate time. Spruce can help designers request complex multi-view animations and not have the developers cringe at the prototype. GradleAdd the following to your project's root build.gradle file repositories {
maven {
url "https://dl.bintray.com/bfears/maven"
}
} Add the following to your project's build.gradle file dependencies {
implementation 'com.willowtreeapps.spruce:spruce-android:1.1.0'
} DocumentationFor javadocs checkout the documentation for more information. Basic UsageAnimator spruceAnimator = new Spruce
.SpruceBuilder(parentViewGroup)
.sortWith(new Default(/*interObjectDelay=*/50L))
.animateWith(new Animator[] {DefaultAnimations.shrinkAnimator(parentViewGroup, /*duration=*/800)})
.start(); Checkout the builder documentation for more information. Preparing for AnimationSpruce comes packed with Running the AnimationUse the following command to run a basic animation on your view. Animator spruceAnimator = new Spruce
.SpruceBuilder(parentViewGroup)
.sortWith(new DefaultSort(/*interObjectDelay=*/50L))
.animateWith(animators)
.start(); Checkout default animation documentation for more information. Using a SortFunctionLuckily, Spruce comes with 8 LinearSort sort = new LinearSort(/*interObjectDelay=*/100L, /*reversed=*/false, LinearSort.Direction.TOP_TO_BOTTOM); In this example we have created a Animator spruceAnimator = new Spruce
.SpruceBuilder(parentViewGroup)
.sortWith(new LinearSort(/*interObjectDelay=*/100L, /*reversed=*/false, LinearSort.Direction.TOP_TO_BOTTOM))
.animateWith(DefaultAnimations.shrinkAnimator(parentViewGroup, /*duration=*/800))
.start(); Definitely play around with the stock The AnimatorsThe animations used in Spruce are produced by leveraging the Standard AnimationThe Sort FunctionsWith all different types of animations, especially those dealing with subviews, we have to consider a way in which we want to animate them. Some views can have 0 subviews while others may have hundreds. To handle this, we have the notion of a The SortFunction InterfaceA very simple interface that requires classes to extend the following class public abstract class SortFunction {
public abstract List<SpruceTimedView> getViewListWithTimeOffsets(ViewGroup parent, List<View> children);
} What the above class needs to do is take in a About Sort FunctionsTo make sure that developers can use Spruce out of the box, we included about 8 stock
Check out the docs here for more information View Exclusion FeatureSpruce Animate all the views inside the view group. One of the key tips for pulling the best performance out of an Android app is to maintain a flat hierarchy. Spruce is now Introducing a new Exclusion feature.
Animator spruceAnimator = new Spruce
.SpruceBuilder(parentViewGroup)
.sortWith(new LinearSort(/*interObjectDelay=*/100L, /*reversed=*/false, LinearSort.Direction.TOP_TO_BOTTOM))
.excludeViews(getExcludedViewIds(), NORMAL_MODE)
//or
.excludeViews(getExcludedViewPosition(), R_L_MODE)
.start(); Sort Function InterpolatorsSpruce now allows the user to control the overall flow of sort function using Interpolators. Animator spruceAnimator = new Spruce
.SpruceBuilder(parentViewGroup)
.sortWith(new LinearSort(/*interObjectDelay=*/100L, /*reversed=*/false, LinearSort.Direction.TOP_TO_BOTTOM))
.addInterpolator(new LinearInterpolator())
.start(); Spruce gives you a wide variety of stock interpolators to choose from.
Checkout interpolator documentation for more information. Spruce DynamicsSpruce now supports Dynamic Animations. Spruce Dynamics is an extension of the androidx dynamic animations. These are the option that SpruceDynamics exposes to the developers:
You can create your own Spring/Fling animations from SpruceDynamics and add them to the '.animateWith' function for playing the animations in the respective ViewGroup Animator spruceAnimator = new Spruce
.SpruceBuilder(parentViewGroup)
.sortWith(new LinearSort(/*interObjectDelay=*/100L, /*reversed=*/false, LinearSort.Direction.TOP_TO_BOTTOM))
.animateWith(DefaultAnimations.dynamicTranslationUpwards(parent))
.start(); Above all these, With spruce, you can implement a combination of both Android Animations and Spruce Dynamics at the same time. animators = new Object[]{
DefaultAnimations.dynamicTranslationUpwards(parent),
DefaultAnimations.dynamicFadeIn(parent),
DefaultAnimations.shrinkAnimator(parent,800)
};
Animator spruceAnimator = new Spruce
.SpruceBuilder(parentViewGroup)
.sortWith(new LinearSort(/*interObjectDelay=*/100L, /*reversed=*/false, LinearSort.Direction.TOP_TO_BOTTOM))
.animateWith(animators)
.start(); Stock AnimatorsTo make everybody's lives easier, the stock animators perform basic
Experiment which ones work for you! If you think of anymore feel free to add them to the library yourself! Example AppUse the example app to find the right Contributing to SpruceContributions are more than welcome! Please see the Contributing Guidelines and be mindful of our Code of Conduct. Issues or Future IdeasIf part of Spruce is not working correctly be sure to file a Github issue. In the issue provide as many details as possible. This could include example code or the exact steps that you did so that everyone can reproduce the issue. Sample projects are always the best way :). This makes it easy for our developers or someone from the open-source community to start working! If you have a feature idea submit an issue with a feature request or submit a pull request and we will work with you to merge it in! Third Party BindingsReact NativeYou may now use this library with React Native via the module here About WillowTree!We build apps, responsive sites, bots—any digital product that lives on a screen—for the world’s leading companies. Our elite teams challenge themselves to build extraordinary experiences by bridging the latest strategy and design thinking with enterprise-grade software development. Interested in working on more unique projects like Spruce? Check out our careers page. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论