Jemil Riahi
Jemil Riahi

Reputation: 1370

Android expand view animation

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.

Upvotes: 1

Views: 4874

Answers (2)

azizbekian
azizbekian

Reputation: 62189

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

TransitionManager.beginDelayedTransition(viewGroup);

ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
layoutParams.height = endValue;
view.invalidate();

Upvotes: 1

Jemil Riahi
Jemil Riahi

Reputation: 1370

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?

Upvotes: 1

Related Questions