Android 动画中的多重平移动画集不起作用
我希望我的ImageView首先从屏幕的中心移动到屏幕左侧的外部,然后我希望它从屏幕右侧的外部移动到屏幕的中心 但它只是从屏幕的右侧进入中间,然后暂停,然后进入屏幕的左侧。不管我怎么做,它都能做到。代码如下:Android 动画中的多重平移动画集不起作用,android,animation,multiplication,Android,Animation,Multiplication,我希望我的ImageView首先从屏幕的中心移动到屏幕左侧的外部,然后我希望它从屏幕右侧的外部移动到屏幕的中心 但它只是从屏幕的右侧进入中间,然后暂停,然后进入屏幕的左侧。不管我怎么做,它都能做到。代码如下: public void onWindowFocusChanged(boolean hasFocus) { // TODO Auto-generated method stub super.onWindowFocusChanged(hasFocus); Display
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);
}
});
}