Jaesuk Park
Jaesuk Park

Reputation: 25

Increase Relative layout width to the left and to the right

I want my RelativeLayout to spread with both direction left to right and right to left

I've made several research and I've got a answer for left to right spread Animation with ValueAnimator.

ValueAnimator.ofInt(0, width);

but when I reverse it then it disappears. It works same as

ValueAnimator.ofInt(width,0);

I've already tried .reverse() function. But this was not a solution.

Is there any idea for Right to Left Animation? Or Do I have to Use a other solution with xml. But I want to do with dynamically way as much as possible.

Edit : I've made more research and found some way.

Increase Android button's width from right to left

This is exactly what I want to be worked. But this is something on ViewGroup...

Upvotes: 0

Views: 135

Answers (1)

Jaesuk Park
Jaesuk Park

Reputation: 25

Increase LinearLayout width from either right or left

Try this trick

This Logic is like moving left and the width

With this Logic I solved my problem

I used ValueAnimator and animation is from onAnimationUpdate value

 params.leftMargin = xParams - (Integer)animation.getAnimatedValue() + width;
 params.width = (Integer)animation.getAnimatedValue();

will do the trick

Upvotes: 1

Related Questions