//FAB Launch
Animation makeInAnimation = AnimationUtils.makeInAnimation(getBaseContext(), false);
makeInAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) { }
@Override
public void onAnimationRepeat(Animation animation) { }
@Override
public void onAnimationStart(Animation animation) {
_fab.setVisibility(View.VISIBLE);
}
});
Animation makeOutAnimation = AnimationUtils.makeOutAnimation(getBaseContext(), true);
makeOutAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
_fab.setVisibility(View.INVISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) { }
@Override
public void onAnimationStart(Animation animation) { }
});
if (_fab.isShown()) {
_fab.startAnimation(makeOutAnimation);
}
if (!_fab.isShown()) {
_fab.startAnimation(makeInAnimation);
}
// Click to view FAB
_fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlphaAnimation animation1 = new AlphaAnimation(1, 0);
animation1.setDuration(1200);
animation1.setStartOffset(1000);
animation1.setFillAfter(true);
_fab.startAnimation(animation1);
}
});
//Change FAB Background color
final ObjectAnimator animator = ObjectAnimator.ofInt(_fab, "backgroundTint", Color.rgb(0, 121, 107), Color.rgb(226, 143, 34));
animator.setDuration(2000L);
animator.setEvaluator(new ArgbEvaluator());
animator.setInterpolator(new DecelerateInterpolator(2));
animator.addUpdateListener(new ObjectAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int animatedValue = (int) animation.getAnimatedValue();
_fab.setBackgroundTintList(android.content.res.ColorStateList.valueOf(animatedValue));
}
});
animator.start();
//FAB Tab to change icons
final int[] ids = {R.drawable.icon1,R.drawable.icon2,R.drawable.icon3};
valueAnimator = android.animation.ValueAnimator.ofInt(0, ids.length - 1).setDuration(1000);
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.addUpdateListener(new android.animation.ValueAnimator.AnimatorUpdateListener() {
int i = -1;
@Override
public void onAnimationUpdate(android.animation.ValueAnimator animation) {
int animatedValue = (int) animation.getAnimatedValue();
if(i!=animatedValue) {
_fab.setImageDrawable(getResources().getDrawable(ids[animatedValue]));
i = animatedValue;
}
}
});
}
private android.animation.ValueAnimator valueAnimator;
public void nothing() {
//Use it on Button to reverse animator
valueAnimator.reverse();
_fab.setRippleColor (Color.parseColor ( "#D50000"));
Video Halp
Thank Bro
ReplyDeleteWait 30 minutes, the whole video is made, which will be uploaded in 30 minutes.
DeleteNeed help
ReplyDeleteHow add buttons in fab button