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);
兩種方法加載是一樣的,就是不知道你所謂的閃爍效果是怎樣的?(吐槽一下,你就一個動畫,干嘛要用set?)