单个动画 - 多个视图 [英] Single Animation - Multiple Views

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

问题描述

有没有办法同时为多个视图设置动画?

Is there any way to animate multiple views at the same time?

我想做的是翻译动画:

我有 5 个 TextViews 和 4 个彩色条带(带背景的普通 RelativeLayouts).在动画开始时,stips 与 TextViews 堆叠在一个水平行中.最后我希望所有的 TextViews 堆叠在条带之间:

I have 5 TextViews and 4 coloured strips (plain RelativeLayouts with a background). At the start of the animations, the stips are stacked with the TextViews in a horizontal row. At the end I want all the TextViews stacked between the strips:

这是一张非常简单的图,但它展示了我想要做的事情.有没有办法用动画来做到这一点,或者我必须使用画布动画.

This is a very simple drawing, but it demonstrates what I want to do. Is there any way of doing this with animations, or do I have to use canvas animations.

推荐答案

创建动画对象,然后在所有视图上同时使用 startAnimation.所以它会是这样的:

Create your animation objects, then use startAnimation collectively on all views at the same time. So it would be something like this:

TranslateAnimation anim1;
TranslateAnimation anim2;
TranslateAnimation anim3;

// Setup the animation objects

public void startAnimations()
{
   //... collect view objects
   view1.startAnimation(anim1);
   view2.startAnimation(anim2);
   view3.startAnimation(anim3);
}

请注意,您同时播放的动画越多,速度就越慢.

Just note that the more animations you have going on at once, the slower it's going to be.

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

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