如何在Android中创建移动/调整动画大小?
有人知道Android动画吗?我想创建如下内容:如何在Android中创建移动/调整动画大小?,android,animation,Android,Animation,有人知道Android动画吗?我想创建如下内容: 我的设备屏幕中央有一个大图像 此图像变小(通过动画)并进入设备屏幕的一角 下面的顺序是这样的: 任何提示都将不胜感激!提前谢谢 使用ViewPropertyAnimator,方法包括scaleXBy()和translateYBy()。通过在API级别11+的视图上调用animate(),可以获得ViewPropertyAnimator。如果您支持较旧的设备,则提供一个类似于工作的后端端口 您可能还希望阅读: 我有一门同时旋转和移动的课
- 我的设备屏幕中央有一个大图像李>
- 此图像变小(通过动画)并进入设备屏幕的一角李>
任何提示都将不胜感激!提前谢谢 使用
ViewPropertyAnimator
,方法包括scaleXBy()
和translateYBy()
。通过在API级别11+的视图上调用animate()
,可以获得ViewPropertyAnimator
。如果您支持较旧的设备,则提供一个类似于工作的后端端口
您可能还希望阅读:
我有一门同时旋转和移动的课。它的成本很高,但适用于所有API版本
public class ResizeMoveAnimation extends Animation {
View view;
int fromLeft;
int fromTop;
int fromRight;
int fromBottom;
int toLeft;
int toTop;
int toRight;
int toBottom;
public ResizeMoveAnimation(View v, int toLeft, int toTop, int toRight, int toBottom) {
this.view = v;
this.toLeft = toLeft;
this.toTop = toTop;
this.toRight = toRight;
this.toBottom = toBottom;
fromLeft = v.getLeft();
fromTop = v.getTop();
fromRight = v.getRight();
fromBottom = v.getBottom();
setDuration(500);
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float left = fromLeft + (toLeft - fromLeft) * interpolatedTime;
float top = fromTop + (toTop - fromTop) * interpolatedTime;
float right = fromRight + (toRight - fromRight) * interpolatedTime;
float bottom = fromBottom + (toBottom - fromBottom) * interpolatedTime;
RelativeLayout.LayoutParams p = (LayoutParams) view.getLayoutParams();
p.leftMargin = (int) left;
p.topMargin = (int) top;
p.width = (int) ((right - left) + 1);
p.height = (int) ((bottom - top) + 1);
view.requestLayout();
}
}
谢谢你的公共软件。当然,这很有帮助!我们如何使用前面提到的视图来调用此调整大小动画