从特定位置从上到下开始简单的动画

编程入门 行业动态 更新时间:2024-10-25 22:23:36
本文介绍了从特定位置从上到下开始简单的动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要制作一个从上到下执行动画的文本视图,并且动画以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);

希望这会有所帮助:)

更多推荐

从特定位置从上到下开始简单的动画

本文发布于:2023-10-08 03:02:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471315.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:从上到下   位置   简单   动画

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!