`
houniao1990
  • 浏览: 13475 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

android 动画调换上下布局

阅读更多

android 动画调换上下布局

 

之前使用TranslateAnimation实现,感觉复杂又不好搞,实际上用ViewPropertyAnimator 可以很简单解决。

代码如下:

public void swapViewUpDown(int upViewId, final int downViewId) {
		final View upView = (View) findViewById(upViewId);
		final View downView = (View) findViewById(downViewId);
		upView.animate().translationYBy(upView.getHeight()).setDuration(ANIMATION_DURATION)
		.setInterpolator(new BounceInterpolator());
		downView.animate().translationYBy(-downView.getHeight()).setDuration(ANIMATION_DURATION)
		.setInterpolator(new BounceInterpolator());

	}

 

 4种动画插值器

OvershootInterpolator:冲过了头回滚一点的效果

AnticipateInterpolator:出发前先后退一步再前冲的动画效果

AnticipateOvershootInterpolator:以上两种的结合

BounceInterpolator:自由落地后回弹的效果

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics