如何在动画Android的视图的转换 [英] How to animate the translation of a view in Android

查看:119
本文介绍了如何在动画Android的视图的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,如果有人知道如何编程制作动画的意见翻译,而不是XML,我那里有这些看法应该去的坐标。
这是视图的创建:

  RelativeLayout.LayoutParams PARAMS =新RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
params.leftMargin = X;
params.topMargin = Y;
my_view.setLayoutParams(PARAMS);
holder.addView(my_view);

我需要移动和动画这一观点与其他X1,Y1的位置。谢谢!


解决方案

  TranslateAnimation动画=新TranslateAnimation(fromX,TOX,弗罗米,玩具);
layout.startAnimation(动画);

这应该工作。

I would like to know if somebody knows how to animate the translation of the views programatically, not XML, I have the coordinates where these views should go. This is the creation of the view:

RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.leftMargin = x;
params.topMargin = y;
my_view.setLayoutParams(params);
holder.addView(my_view);

I need to move and animate this view to other x1,y1 position. Thanks!

解决方案

TranslateAnimation animation = new TranslateAnimation(fromX,ToX,FromY,ToY);
layout.startAnimation(animation);

This should work.

这篇关于如何在动画Android的视图的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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