楼主有没有看CPU的利用率和内存的使用情况?卡可能是你的机器跑不来,如果想显示那么多动画而不用加速的话很难从根本上解决问题。

解决方案 »

  1.   

    一下是部分代码,进行了简化,外部控制ViewFlipper 的更新是因为有其他动作要做,没有使用它的startflipping 
    这个ViewFlipper 的动画每隔几秒要一次,动画时间大约3秒,间隔时间为10秒左右,
        Animation inAnimation  ;
        Animation outAnimation  ;
        private ViewFlipper mVflipper;
        
        private void _doAnimation (){
            inAnimation = AnimationUtils.loadAnimation(mContext, R.anim.in);        
            outAnimation = AnimationUtils.loadAnimation(mContext, R.anim.out);
            mVflipper = (ViewFlipper) findViewById(R.id.flipper);
            
            mHandler.removeMessages(1);
            Message msg = mHandler.obtainMessage(1);
            mHandler.sendMessageDelayed(msg, 10000);
            
        }
        private final Handler mHandler = new Handler() {
            public void handleMessage(Message msg) {
                swtich(msg.what){
                    case 1 :
                        mVflipper.setInAnimation(inAnimation);
                        mVflipper.setOutAnimation(outAnimation);
                        mVflipper.showNext();
                              mHandler.removeMessages(1);
                        msg = obtainMessage(1);
                        sendMessageDelayed(msg, 10000);
                        break ;
                    default :
                        break ;
                }
            }
        }以上动画自己执行时没有问题。另外也有一段代码 也是ViewFlipper  ,当点击按钮时 会调用ViewFlipper 的showNext()并且伴有动画,当两段动画同时进行时 ,动画就会变得很卡 ,运行缓慢
      

  2.   

    你可以考虑为每个动画效果创建一个新的线程,在各自的线程里去实现动画效果。例如这样的new Thread(new Runnable(){
    public void run(){
    while(flag && seekBar.getProgress()<100){
    try {
    Thread.sleep(1000);
    } catch (InterruptedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }

    mHandler.post(new Runnable(){
    public void run(){
    seekBar.setProgress(seekBar.getProgress()+1);
    }
    });
    }
    }
    }).start();
      

  3.   


    我中间每次都要更新mVflipper中layout中的东西,每次显示是要更换内容,所以要外部控制动作的