Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Button Doesn't Respond After Animation

Tags:

java

android

I have a basic animation of a button after it is pressed currently in my application. After the button finishes animating, I can no longer click on it. It doesn't even press with an orange highlight.

Any help?

Here's my code:

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

animation = new AnimationSet(true);
animation.setFillAfter(true);
Animation translate = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 5.0f);
translate.setDuration(500);
animation.addAnimation(translate);

LayoutAnimationController controller = new LayoutAnimationController(animation, 0.25f);


generate = (Button)findViewById(R.id.Button01);

generate.setOnClickListener(new View.OnClickListener(){
    public void onClick(View v){
            keyFromTop();

        }
    });


}

public void keyFromTop(){   
    generate.setAnimation(animation);    
}
like image 563
Kleptine Avatar asked Jan 24 '10 02:01

Kleptine


1 Answers

Animations affect only the drawing of widgets, which means after the animation is done, your button is still at its previous location. You need to manually update the layout parameters of your button if you want to move it to the new location. Also, your AnimationSet and your AnimationController are useless.

like image 166
Romain Guy Avatar answered Sep 22 '22 17:09

Romain Guy