android - AnimationSet with setStartOffset not working -


i'm trying run few animations (one after another) on view using animationset

scale 1 --> 0 , 0 --> 1

animationset animationset = new animationset(true); animationset.setinterpolator(new acceleratedecelerateinterpolator());  scaleanimation animation1 = new scaleanimation(1f, 0f, 1f, 0f, animation.relative_to_self, 0.5f, animation.relative_to_self, 0.5f); animation1.setduration(500);  scaleanimation animation2 = new scaleanimation(0f, 1f, 0f, 1f, animation.relative_to_self, 0.5f, animation.relative_to_self, 0.5f); animation2.setduration(500); animation2.setstartoffset(500);  animationset.addanimation(animation1); animationset.addanimation(animation2);  mfloatingactionbutton.startanimation(animationset); 

the view disappear , after sec appear again. no animation.

if remove setstartoffset(...) can see animation, not 1 want.

what missing here?

chaining animations using start offset behaves expected. there several ways achieve effect want:

1) using scaleanimations, chain animations using listeners (start second animation on onanimationend callback).

2) using animatorsets (as opposed animationsets) playsequentially.

simplified code option 1:

final view theview = findviewbyid(r.id.the_view); final scaleanimation scaleanimation1 = new scaleanimation(1,0,1,0); final scaleanimation scaleanimation2 = new scaleanimation(0,1,0,1); scaleanimation1.setanimationlistener(new animation.animationlistener() {     @override     public void onanimationstart(animation animation)     {     }      @override     public void onanimationend(animation animation)     {         theview.startanimation(scaleanimation2);     }      @override     public void onanimationrepeat(animation animation)     {     } }); 

simplified code option 2:

final view theview = findviewbyid(r.id.the_view);  objectanimator animscalexsmaller = objectanimator.offloat(theview, "scalex", 0f); objectanimator animscaleysmaller = objectanimator.offloat(theview, "scaley", 0f); animatorset animscalexysmaller = new animatorset(); animscalexysmaller.setduration(500); animscalexysmaller.playtogether(animscalexsmaller, animscaleysmaller);  objectanimator animscalexbigger = objectanimator.offloat(theview, "scalex", 1f); objectanimator animscaleybigger = objectanimator.offloat(theview, "scaley", 1f); animatorset animscalexybigger = new animatorset(); animscalexybigger.setduration(500); animscalexybigger.playtogether(animscalexbigger, animscaleybigger);  animatorset animscalebounce = new animatorset(); animscalebounce.playsequentially(animscalexysmaller, animscalexybigger); animscalebounce.setinterpolator(new acceleratedecelerateinterpolator()); animscalebounce.start(); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -