I have been looking around online for a while, but I can't seem to find it anywhere. I have a floating action button that I have working already. It shows up and is clickable etc, but at this point has nothing wired up to it. Before I go any further I want to know how to make it animate on startup.
On the material design page for FAB it shows like a sprout type animation where it comes from the correct location, but animates to its intended size. Found here .
Any info is appreciated.
You can take a look at the Behavior
class inside of FloatingActionButton
. For example this is how the enter animation is implemented:
private void animateIn(FloatingActionButton button) {
button.setVisibility(0);
if(VERSION.SDK_INT >= 14) {
ViewCompat.animate(button).scaleX(1.0F).scaleY(1.0F).alpha(1.0F).setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR).withLayer().setListener((ViewPropertyAnimatorListener)null).start();
} else {
Animation anim = android.view.animation.AnimationUtils.loadAnimation(button.getContext(), anim.fab_in);
anim.setDuration(200L);
anim.setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
button.startAnimation(anim);
}
}
You want to use AnimationUtils
here. Here is an easy tutorial: Android Animations
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.