android - animation does not apply to a button with background -


i have button defined in layout file. when button clicked, assign animation follow:

   animation animation = new rotateanimation(0.0f, 360.0f,                     animation.relative_to_self, 0.5f, animation.relative_to_self,                     0.5f);             animation.setrepeatcount(-1);             animation.setduration(2000); mybutton.setanimation(animation); 

all things work fine point. problem raised when set background button specially android:background="@null" in button definition.

any idea on how fix ? thanks.

i have tried in project , works on button background.

private objectanimator rotationanimator; 

and functions control animation

private void startanimation(int animationduration) {      if (rotationanimator == null || !rotationanimator.isrunning()) {         // can tweak needs         keyframe kf0 = keyframe.offloat(0f, 0f);         keyframe kf2 = keyframe.offloat(0.5f, 180f);         keyframe kf1 = keyframe.offloat(1f, 360f);          propertyvaluesholder pvhrotation = propertyvaluesholder.ofkeyframe("rotation", kf0, kf1, kf2);         rotationanimator = objectanimator.ofpropertyvaluesholder(your_button_here, pvhrotation);         rotationanimator.setrepeatcount(objectanimator.infinite);         rotationanimator.setinterpolator(new linearinterpolator());         rotationanimator.setduration(animationduration);         rotationanimator.start();     }     else {         log.d("animation", "i running!");     } }  private void stopanimation() {     if (rotationanimator != null) {         rotationanimator.cancel();         rotationanimator = null;     } }  private boolean getanimationrunning() {     return rotationanimator != null && rotationanimator.isrunning(); } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -