Android stop button animation at an event
I am trying to revive a button. Animation is working, but I can not stop it.
First I have defined a property in class
Personal Object Animator Animator BTN;
Then when an event inside an event ocur i started the animation
@ override public zero text message (last message message) {runOnUiThread (new runnab ) {@ Override Public Wide Run (see (myBtn.getVisibility () == View Visual & amp; MessageGet Visibility ()! = View .Visual) {myBtn.setBackground (context.getResources (.) GetDrawable (R) ) .drawable.red_round_button ;; animatorBtn = ObjectAnimator.ofFloat (myBtn, "Translation Y", -100F, 0f); Animator BT.N.According (1000); // 1sec Animator BT.N.set InternetPolter (New Left Animation BTN.SetrippetCount (ValueEnimeter.INFINITE); Animator BTN. Start ();} MessageView Written Message Message (Message);}})}}
Second I am trying to stop it but at the event
@OnClick (R.id.my_btn) void onClickMyBtn () {runOnUiThread (New Runnabal) {@Override Public Run zero () {myBtn.setBackground (context.getResources () .getDrawable (R.drawable.green_round_button)); If (animatorBtn! = Null) {animatorBtn.cancel ();}}}); }
thanks
No comments:
Post a Comment