将一个同一个动画应用于两个不同的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 usestartAnimationon 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 callinvalidate()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

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

更多相关文章

  1. Android(安卓)5.1 Lollipop Phone工作流程浅析(十三)__InCallAct
  2. (4.1.23.1)Android(安卓)属性动画(Property Animation) 完全解析 (上)
  3. Android笔记——Day1 *Activity生命周期 *Activiity切换效果
  4. android 动画原理源码分析之Animation
  5. Android开发之动画实现
  6. android开机动画播放流程
  7. 逐帧动画入门
  8. Android动画Animator开发问题
  9. 我的Android进阶之旅------>Android之Animations动画详解

随机推荐

  1. Android(安卓)studio升级3.0.1遇到的坑及
  2. android跑马灯效果实现(一直滚动不受影响)
  3. android 4.0 屏蔽 HOME_KEY 和 RECENT_AP
  4. Android(安卓)联系人数据库介绍以及对联
  5. [置顶] android开发各种相关干货
  6. PhoneGap是什么?
  7. Android(安卓)混淆
  8. android 设置闹钟及通知
  9. Android(安卓)Studio插件之快速findViewB
  10. requires plug-in org.eclipse.wst.sse.u