1

我需要制作一个从上到下执行动画的文本视图,并且动画从 y 值 50 开始。怎么做?提前致谢。

4

1 回答 1

0

您可以使用翻译动画。TranslateAnimation 使用增量,因此要计算距屏幕顶部 50px 的位置,减去视图顶部并添加 50。在此示例中,我通过向 fromY 添加一些值来设置 toY。这是代码:

int fromY = 50 - view.getTop();
int toY = fromY + someValue;
TranslateAnimation animation = new TranslateAnimation(0, 0, fromY, toY);
animation.setDuration(someDuration);
view.startAnimation(animation);

希望这可以帮助 :)

于 2013-09-25T09:28:06.053 回答