Android中一个动画应用于两个View中不同步的问题

将一个同一个动画应用于两个不同的View中,想让两个View同时向一个方向移动相同的距离。关键代码如下:

		Animation topAnimation = new TranslateAnimation(0, 0, 0, -heightOfTopTrans);
		topAnimation.setDuration(durationMillis);
//		topAnimation.setInterpolator(this, anim.accelerate_interpolator);
		topAnimation.setFillAfter(true);
		mTopLayout.startAnimation(topAnimation);
		mGridView.startAnimation(topAnimation);

但是事实上于理论的相反,从目前的效果来看,mTopLayout要比mGridView的动画开始的慢,感觉就是先开始的后执行。

为什么会出现这种情况?在网上进行相关搜索后,发现也有人遇到同样的问题,但是没有给出解决方案。


在下面的网页中找到了一些相关的信息:http://stackoverflow.com/questions/9217305/single-animation-multiple-views


其中有部分人的回答如下:



Won't this cause them to be out of sync (not essential here), especially the ones that are started later? –  Matthew  Feb 9 at 19:58
 
Not really. Basically what happens is when you use startAnimation on a view, it starts invalidating itself until it's reached the desired location. When you call it on all the views at once, they'll all call invalidate() on themselves, then on the next drawing pass each view will be drawn in their next frame. Since you're calling all this on the UI thread anyway, none of the animations will start until you've returned from that method. NOTE: Using the pre-Honeycomb animation framework merely moves the visual portion of the view. The user won't be able to click on it. –  DeeV  Feb 9 at 20:10

目前 还没有找到相关的解决的方法抓狂,如果有高人知道,求指点。

你可能感兴趣的:(thread,android,UI,user,animation,each)