1

I have a bottomBar that i would like to expand. I think i know how to do it with animations.

But according to What is the difference between an Animator and an Animation?

If i use old animations. Then the buttons would not be relocated. Only visually.

How could i achieve this with Animators.

What i am trying to achieve

enter image description here

So could someone nudge me in the right direction.

Community
  • 1
  • 1
Jemil Riahi
  • 1,360
  • 5
  • 18
  • 38

2 Answers2

1

This solved my problem.

    public static ValueAnimator slideAnimator(int start, int end, final View view, int duration) {
    ValueAnimator animator = ValueAnimator.ofInt(start, end);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
            layoutParams.height = val;
            view.setLayoutParams(layoutParams);
        }
    });
    animator.setDuration(duration);
    return animator;
}

Credit to: Android property animation: how to increase view height?

Community
  • 1
  • 1
Jemil Riahi
  • 1,360
  • 5
  • 18
  • 38
1

Well, that can be done with a "one-liner":

TransitionManager.beginDelayedTransition(viewGroup);

ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
layoutParams.height = endValue;
view.invalidate();
azizbekian
  • 60,783
  • 13
  • 169
  • 249