This repository has been archived by the owner on Oct 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Documentation
Dmytro Tarianyk edited this page Apr 11, 2016
·
5 revisions
Example code:
final FloatingActionMenu fam = (FloatingActionMenu) findViewById(R.id.menu_green);
AnimatorSet set = new AnimatorSet();
ObjectAnimator scaleOutX = ObjectAnimator.ofFloat(fam.getMenuIconView(), "scaleX", 1.0f, 0.2f);
ObjectAnimator scaleOutY = ObjectAnimator.ofFloat(fam.getMenuIconView(), "scaleY", 1.0f, 0.2f);
ObjectAnimator scaleInX = ObjectAnimator.ofFloat(fam.getMenuIconView(), "scaleX", 0.2f, 1.0f);
ObjectAnimator scaleInY = ObjectAnimator.ofFloat(fam.getMenuIconView(), "scaleY", 0.2f, 1.0f);
scaleOutX.setDuration(50);
scaleOutY.setDuration(50);
scaleInX.setDuration(150);
scaleInY.setDuration(150);
scaleInX.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
fam.getMenuIconView().setImageResource(fam.isOpened()
? R.drawable.ic_close : R.drawable.ic_star);
}
});
set.play(scaleOutX).with(scaleOutY);
set.play(scaleInX).with(scaleInY).after(scaleOutX);
set.setInterpolator(new OvershootInterpolator(2));
fam.setIconToggleAnimatorSet(set);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setLabelColors(ContextCompat.getColor(this, R.color.grey),
ContextCompat.getColor(this, R.color.light_grey),
ContextCompat.getColor(this, R.color.white_transparent));
fab.setLabelTextColor(ContextCompat.getColor(this, R.color.black));