I\'m trying to move button (with animation) upon click. I want it to move 100 pixels to the bottom on first click, 100 pixels up on second, 100 pixels to the bottom on third
An easy solution is to add padding in the onAnimationEnd function:
public void moveAnimation() {
move = new TranslateAnimation(Pos-50, 0, 0, 0);
Pos += 50.0;
move.setDuration(1500);
move.setFillAfter(true);
move.setAnimationListener(new AnimationListener(){
@Override
public void onAnimationEnd(Animation arg0) {
int x=(int) (Pos-50),y=0;
i.setPadding(x,y,0,0);
x+=50; y+=0;
i.setPadding(x,y,0,0);
}
@Override
public void onAnimationRepeat(Animation arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationStart(Animation arg0) {
// TODO Auto-generated method stub
}
});
i.startAnimation(move);
}
where i = (ImageView) findViewById(R.id.imgAMD);