本文介绍了从特定位置从上到下开始简单的动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要制作一个从上到下执行动画的文本视图,并且动画以y值50开始.该怎么做?预先感谢.
I need to make a textview that perform an animation from top to bottom and the animation start with the y value 50. How to do it? Thanks in advance.
推荐答案您可以使用TranslateAnimation. TranslateAnimation使用增量,因此要计算从屏幕顶部开始50px的位置,减去视图顶部和顶部加50. 在此示例中,我通过向fromY添加一些值来设置toY. 这是代码:
You can use TranslateAnimation. TranslateAnimation uses deltas, so to calculate the position of 50px from the top of the screen, subtract the top of the view & add 50. In this example, I set the toY by adding some value to the fromY. Here's the code:
int fromY = 50 - view.getTop(); int toY = fromY + someValue; TranslateAnimation animation = new TranslateAnimation(0, 0, fromY, toY); animation.setDuration(someDuration); view.startAnimation(animation);希望这会有所帮助:)
更多推荐
从特定位置从上到下开始简单的动画
发布评论