放大图像并将图像从右下角移动到左上角并缩小
Scale up and move image from bottom right to top left with zoom out
我已经使用这个答案移动和缩小图像(从左上角到右下角)并且工作正常..
现在我想要这个反转,即图像放大并从右下角移动到左上角。我刚刚将源和目标以及 ScaleAnimation(1f, 0f, 1, 0f, 替换为 ScaleAnimation( 0f, 1f, 1, 1f ...
缩放工作正常..但图像仍在从左上角移动到右下角..
谁能帮帮我??
可以这么简单:
yourView.animate().scaleX(1.0f).scaleY(1.0f).x(0.0f).y(0.0f);
这假定 yourView
的父布局是层次结构中的根布局。
根据您分享的link:
- 不要更改源视图和目标视图
更改以下代码:
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);
我已经使用这个答案移动和缩小图像(从左上角到右下角)并且工作正常..
现在我想要这个反转,即图像放大并从右下角移动到左上角。我刚刚将源和目标以及 ScaleAnimation(1f, 0f, 1, 0f, 替换为 ScaleAnimation( 0f, 1f, 1, 1f ... 缩放工作正常..但图像仍在从左上角移动到右下角.. 谁能帮帮我??
可以这么简单:
yourView.animate().scaleX(1.0f).scaleY(1.0f).x(0.0f).y(0.0f);
这假定 yourView
的父布局是层次结构中的根布局。
根据您分享的link:
- 不要更改源视图和目标视图
更改以下代码:
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);