【问题标题】:Scale up and move image from bottom right to top left with zoom out放大并将图像从右下角移动到左上角并缩小
【发布时间】:2017-04-04 15:04:01
【问题描述】:

我已经使用这个答案来移动和缩小图像(从左上角到右下角),它工作正常..

https://stackoverflow.com/a/23564351/2389804

现在我希望这个相反的图像被放大并从右下角移动到左上角。我刚刚将源和目标以及 ScaleAnimation(1f, 0f, 1, 0f, 替换为 ScaleAnimation(0f, 1f, 1, 1f ... 缩放工作正常..但图像仍在从左上角移动到右下角.. 谁能帮帮我??

【问题讨论】:

    标签: android animation android-animation


    【解决方案1】:

    根据您分享的链接:https://stackoverflow.com/a/23564351/2389804

    • 不要更改源视图和目标视图
    • 更改以下代码:

      ScaleAnimation animation = new ScaleAnimation(1f, 0f, 1, 0f, Animation.ABSOLUTE, endX - startX + startView.getWidth() / 2, Animation.ABSOLUTE, endY - startY + startView.getHeight() / 2);

    收件人:

    ScaleAnimation animation = new ScaleAnimation(0f, 1f, 0, 1f, Animation.ABSOLUTE, endX - startX + startView.getWidth() / 2, Animation.ABSOLUTE, endY - startY + startView.getHeight() / 2);

    【讨论】:

      【解决方案2】:

      可以这么简单:

      yourView.animate().scaleX(1.0f).scaleY(1.0f).x(0.0f).y(0.0f);
      

      这假定yourView 的父布局是层次结构中的根布局。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-08-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-11-14
        • 2016-01-30
        • 2016-01-08
        相关资源
        最近更新 更多