解决方案 »

  1.   

    复制代码
    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会有问题,  改用②③解决