Skip to content
This repository has been archived by the owner on Oct 23, 2020. It is now read-only.

Documentation

Dmytro Tarianyk edited this page Apr 11, 2016 · 5 revisions

Use different icons for closed and opened menu


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);

Change Label's background and text colors

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));
Clone this wiki locally