animationSet1 = new AnimationSet(true);
animationSet2 = new AnimationSet(true);
image2.setVisibility(View.VISIBLE);
Animation animation1 = AnimationUtils.loadAnimation(getActivity(), R.anim.tttxt_fragment_layout_imageview1_anim);
animationSet1.addAnimation(animation1);
Animation animation2 = AnimationUtils.loadAnimation(getActivity(), R.anim.tttxt_fragment_layout_imageview2_anim);
animationSet2.addAnimation(animation2);
image1.startAnimation(animationSet1);
image2.startAnimation(animationSet2);
tttxt_fragment_layout_imageview1_anim:
android:duration="2000"
android:fillAfter="true"
android:fromXDelta="0%"
android:toXDelta="-100%" />
tttxt_fragment_layout_imageview2_anim:
android:duration="2000"
android:fillAfter="true"
android:fromXDelta="100%"
android:toXDelta="0%" />
上面这种方法加载动画为什么闪烁?
下面这样就不闪烁,这不是一样吗?:
AnimationSet animationSet1 = new AnimationSet(true);
AnimationSet animationSet2 = new AnimationSet(true);
image2.setVisibility(View.VISIBLE);
TranslateAnimation ta = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF,
-1f, Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 0f);
ta.setDuration(2000);
animationSet1.addAnimation(ta);
animationSet1.setFillAfter(true);
ta = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f,
Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF,
0f, Animation.RELATIVE_TO_SELF, 0f);
ta.setDuration(2000);
animationSet2.addAnimation(ta);
animationSet2.setFillAfter(true);
//iamgeView 出去 imageView2 进来
image1.startAnimation(animationSet1);
image2.startAnimation(animationSet2);
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。