主要代码如下:

float fromXDelta = context.length;
TranslateAnimation translateAnimation =null;
if (this.context.oldTabViewIndex < this.context.curTabViewIndex) {
fromXDelta = context.length * (this.context.curTabViewIndex - this.context.oldTabViewIndex);
translateAnimation = new TranslateAnimation(0,
fromXDelta, 0.0F, 0.0F);
}else {
fromXDelta = context.length * (this.context.oldTabViewIndex - this.context.curTabViewIndex);
translateAnimation = new TranslateAnimation(0,
fromXDelta*-1, 0.0F, 0.0F);
}
translateAnimation.setAnimationListener(new AnimationListener(){

@Override
public void onAnimationEnd(Animation animation) {
RelativeLayout.LayoutParams aLayoutParams = (RelativeLayout.LayoutParams) context.tab_front_bg
.getLayoutParams();
aLayoutParams.setMargins(context.curTabViewIndex*context.length, 0, 0, 0);
context.tab_front_bg.setLayoutParams(aLayoutParams);
// context.tab_front_bg.clearAnimation();//解决移动后闪烁现象 ①
TranslateAnimation anim = new TranslateAnimation(0,0,0,0);   ②
context.tab_front_bg.setAnimation(anim);               ③
}

@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub

}

@Override
public void onAnimationStart(Animation animation) {

}
});
translateAnimation.setDuration(200);
context.tab_front_bg.startAnimation(translateAnimation);


如没有 ① ② ③ 代码,动画结束后停在动画结束的位置后闪烁一下,  加上①处代码  可以解决 不过Listview会有问题,  改用②③解决

相关文章:

  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-20
  • 2021-09-20
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-20
  • 2021-08-06
  • 2021-09-30
相关资源
相似解决方案