Reputation: 1370
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
So could someone nudge me in the right direction.
Upvotes: 1
Views: 4874
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
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