Image_View startAnimation的问题

huxiaobing1989 2012-04-07 11:04:01
想做一个图片移动的动画效果,图片放在 image_view1 中,下面的代码我定义了一个TranslateAnimation,希望大虾们帮我看看问题在哪。
TranslateAnimation tAnimation=new TranslateAnimation(Animation.ABSOLUTE, 0,
Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0,
Animation.ABSOLUTE, 500);
tAnimation.setInterpolator(new LinearInterpolator());
tAnimation.setDuration(5000);
tAnimation.setFillAfter(true);
image_view1.startAnimation(tAnimation);

我所希望的运行结果是image_view1在屏幕上慢慢向下移动500个像素点,但是在虚拟机上运行之后发现image_view1根本不移动,然后5秒中之后image_view1瞬间跳到了移动500像素之后的目标位置上,中间的动画效果看不见,本人刚接触Android不久,望大牛们指教,问题在哪呢
...全文
312 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
huxiaobing1989 2012-04-07
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

是不是View没有完全加载!
[/Quote]
怎么样判断一个View是不是完全加载了?你只的View是指image_view1吧?
Rain麦子 2012-04-07
  • 打赏
  • 举报
回复
是不是View没有完全加载!
安卓几种属性动画 rotateButton = (Button)findViewById(R.id.rotateButton); scaleButton = (Button)findViewById(R.id.scaleButton); alphaButton = (Button)findViewById(R.id.alphaButton); translateButton = (Button)findViewById(R.id.translateButton); image1 = (ImageView)findViewById(R.id.image1); image2 = (ImageView)findViewById(R.id.image2); image3 = (ImageView)findViewById(R.id.image3); image4 = (ImageView)findViewById(R.id.image4); image5 = (ImageView)findViewById(R.id.image5); rotateButton.setOnClickListener(new RotateButtonListener()); scaleButton.setOnClickListener(new ScaleButtonListener()); alphaButton.setOnClickListener(new AlphaButtonListener()); translateButton.setOnClickListener(new TranslateButtonListener()); } class AlphaButtonListener implements View.OnClickListener { public void onClick(View v) { //创建一个AnimationSet对象,参数为Boolean型, //true表示使用Animation的interpolator,false则是使用自己的 AnimationSet animationSet = new AnimationSet(true); //创建一个AlphaAnimation对象,参数从完全的透明度,到完全的不透明 AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0); //设置动画执行的时间 alphaAnimation.setDuration(2000); //将alphaAnimation对象添加到AnimationSet当中 animationSet.addAnimation(alphaAnimation); //使用ImageView的startAnimation方法执行动画 image1.startAnimation(animationSet); image2.startAnimation(animationSet); image3.startAnimation(animationSet); image4.startAnimation(animationSet); image5.startAnimation(animationSet); Toast.makeText(getApplicationContext(),"消失吧!",Toast.LENGTH_SHORT).show(); } }

80,493

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧