首页 >  Android开发 >  正文

消除Animation残余线条


https://www.panxw.com    栏目:Android开发    标签: Animation , TranslateAnimation     日期:2013-02-26    阅读:

消除Animation残余线条办法:

1,继承TranslateAnimation或RotateAnimation,在applyTransformation中刷新动画parentView的界面。如:

private final class MyTranslateAnimation extends TranslateAnimation {
		private View backgroundView;

		public MyTranslateAnimation(View backgroundView, int fromXType, float fromXValue, int toXType, float toXValue,
				int fromYType, float fromYValue, int toYType, float toYValue) {
			super(fromXType, fromXValue, toXType, toXValue, fromYType, fromYValue, toYType, toYValue);
			this.backgroundView = backgroundView;
		}

		@Override
		protected void applyTransformation(float interpolatedTime, Transformation t) {
			super.applyTransformation(interpolatedTime, t);
			backgroundView.postInvalidate();
		}
}

2,调用:

TranslateAnimation cardAnimation = new MyTranslateAnimation(backgroundView, Animation.RELATIVE_TO_PARENT, 0.01f,
				Animation.RELATIVE_TO_PARENT, 0.35f, Animation.RELATIVE_TO_PARENT, 0.1f, Animation.RELATIVE_TO_PARENT,
				0.1f);
cardAnimation.setDuration(2000);
cardAnimation.setRepeatCount(Animation.INFINITE);
cardAnimation.setRepeatMode(Animation.REVERSE);
imageView.setAnimation(cardAnimation);
本文为原创文章,转载请注明出处:Panxw's Blog » 消除Animation残余线条
如果本站内容帮助到了你,请记得收藏、分享,或打赏支持,谢谢!

上篇: Android AnimationDrawable实现GIF效果动画