【问题标题】:Increase Relative layout width to the left and to the right向左和向右增加相对布局宽度
【发布时间】:2020-09-01 17:09:13
【问题描述】:

我希望我的 RelativeLayout 以从左到右和从右到左两个方向展开

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

ValueAnimator.ofInt(0, width);

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

ValueAnimator.ofInt(width,0);

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

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

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

Increase Android button's width from right to left

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

【问题讨论】:

    标签: android android-animation android-relativelayout


    【解决方案1】:

    Increase LinearLayout width from either right or left

    试试这个技巧

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

    用这个逻辑我解决了我的问题

    我使用了ValueAnimator,动画来自onAnimationUpdate值

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

    会成功的

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-09
      • 2012-04-30
      • 2017-12-28
      • 1970-01-01
      • 2023-03-03
      • 1970-01-01
      相关资源
      最近更新 更多