0

我希望我的 RelativeLayout 以从左到右和从右到左的方向传播

我进行了几项研究,并得到了使用 ValueAnimator 从左到右传播动画的答案。

ValueAnimator.ofInt(0, width);

但是当我反转它时,它就会消失。它的工作原理与

ValueAnimator.ofInt(width,0);

我已经尝试过 .reverse() 函数。但这不是解决方案。

从右到左动画有什么想法吗?或者我是否必须使用其他带有 xml 的解决方案。但我想尽可能多地使用动态方式。

编辑: 我做了更多的研究并找到了一些方法。

从右到左增加Android按钮的宽度

这正是我想要的工作。但这是 ViewGroup 上的东西......

4

1 回答 1

1

从右侧或左侧增加 LinearLayout 宽度

试试这个技巧

这个逻辑就像向左移动和宽度

有了这个逻辑,我解决了我的问题

我使用 ValueAnimator 和动画来自 onAnimationUpdate 值

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

会成功的

于 2020-09-01T09:09:13.350 回答