Button is not clickable after TranslateAnimation

后端 未结 4 652
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-03 21:01

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

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 21:44

    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);

提交回复
热议问题