在AnimationSet中乘以TranslateAnimation不起作用

时间:2012-10-03 14:26:02

标签: android animation multiplying

我希望我的ImageView首先从屏幕中心和左侧屏幕外移动,然后我希望它从屏幕右侧移动到屏幕中心。

但它只是从屏幕右侧进入中心,然后暂停,然后进入屏幕左侧。这样做无论我怎么做。这是代码:

public void onWindowFocusChanged(boolean hasFocus) {
    // TODO Auto-generated method stub
    super.onWindowFocusChanged(hasFocus);
    Display display = getWindowManager().getDefaultDisplay(); 
    int width = display.getWidth(); 

    final AnimationSet anmSet;

    anmSet = new AnimationSet(hasFocus);
    imgCenter = (ImageView)findViewById(R.id.imgCenter);
    btnGoLeft = (ImageButton)findViewById(R.id.btnGoLeft);
    imgCenter.setImageDrawable(list.get(0).getImage());
    TranslateAnimation moveBack = new TranslateAnimation(0,-500, 0, 0);
    moveBack.setDuration(500);
    moveBack.setStartOffset(200);
    anmSet.addAnimation(moveBack);

    TranslateAnimation moveLeft = new TranslateAnimation(width,width/2-imgCenter.getWidth()/2-60, 0, 0); 
    moveLeft.setDuration(500);
    moveLeft.setStartOffset(2000);
    anmSet.addAnimation(moveLeft);

    btnGoLeft.setOnClickListener(new OnClickListener()
    {
        @Override
        public void onClick(View v) {
            imgCenter.startAnimation(anmSet);
        }
    });  
}

0 个答案:

没有答案
相关问题