显示动画
- mShowAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
- Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
- -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
- mShowAction.setDuration(500);
隐藏动画
- mHiddenAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF,
- 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
- Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
- -1.0f);
- mHiddenAction.setDuration(500);
View的显示:
- view.startAnimation(mShowAction);
- view.setVisibility(View.VISIBLE);
View的隐藏:
- view.startAnimation(mHiddenAction);
- view.setVisibility(View.GONE);
我们可以看下ImageView的显示:
- <span style="font-size:10px;">ImageView imageView = (ImageView)findViewById(R.id.imageView1);
- Animation animation = AnimationUtils.loadAnimation(this, R.anim.fade_in);
- imageView.setBackgroundResource(R.drawable.t);
- imageView.startAnimation(animation);</span>
动画效果可以用xml文件定义,定义方法网上很多的,多多参考下。