NineOldAndroids:设置视图支点 [英] NineOldAndroids: set view pivot

查看:146
本文介绍了NineOldAndroids:设置视图支点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是精彩的框架NineOldAndroids,但我找不到任何设置支点在我的动画的看法。具体来说,我试图做一个的scaleX + 的scaleY 动画在左上角边缘的支点,所以 pivotX = 0和 pivotY = 0。蜂窝和超越,我只想设置 MyView的。 setPivotX(0) myView.setPivotY(0),但如何做到这一点的pre-蜂窝设备与NineOldAndroids?我试过如下:

I'm using the wonderful framework NineOldAndroids, but I can't find anything to set the pivot on my animated views. Specifically, I'm trying to do a scaleX + scaleY animation with a pivot on the top-left edge, so pivotX = 0 and pivotY = 0. On Honeycomb and beyond I would just set myView.setPivotX(0) and myView.setPivotY(0), but how to do it for pre-Honeycomb devices with NineOldAndroids? I tried the following:

AnimatorSet set = new AnimatorSet();
set.playTogether(
    ObjectAnimator.ofFloat(myView, "pivotX", -(myView.getWidth() / 2), -(myView.getWidth() / 2)),
    ObjectAnimator.ofFloat(myView, "pivotY", -(myView.getHeight() / 2), -(myView.getHeight() / 2)),
    ObjectAnimator.ofFloat(myView, "scaleX", 0, 1),
    ObjectAnimator.ofFloat(myView, "scaleY", 0, 1),
    ObjectAnimator.ofFloat(myView, "alpha", 0, 1)
);
set.setDuration(1000).start();

,但它不工作时,枢轴停留在视图的中心

but it doesn't work, the pivot stays at the center of the view.

你能帮助我吗?

感谢;)

推荐答案

由于笔者杰克沃顿商学院,这里是解决方案:

Thanks to the author Jake Wharton, here is the solution:

AnimatorProxy.wrap(myView).setPivotX(0);

在任何时候,甚至的的有名为 ObjectAnimator.start()

这篇关于NineOldAndroids:设置视图支点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆