Mar*_*elo 10 animation android
有人知道Android动画吗?我想创建如下内容:
它的类似于下面的序列:
任何提示都将非常感谢!提前致谢!
使用ViewPropertyAnimator
,用类似的方法scaleXBy()
和translateYBy()
.你得到一个ViewPropertyAnimator
通过调用animate()
上View
,在API级别11+.如果您支持较旧的设备,NineOldAndroids提供近乎相同的后端口.
您可能还希望阅读:
我有一个同时旋转和运动的课程.它的成本很高,但适用于所有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();
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11795 次 |
最近记录: |