Android 4.0.x on animatorset.setduration on the pit

Source: Internet
Author: User

<span style= "FONT-SIZE:18PX;" > </span>
<span style= "FONT-SIZE:18PX;" >  Recently used <a target=_blank href= "Https://github.com/skyfishjy/android-ripple-background" >https:// Github.com/skyfishjy/android-ripple-background</a> Open source Control, when the android4.0.x encountered a problem, the original elegant animation has become very fast. </span>
<span style= "FONT-SIZE:18PX;" ></span>
<span style= "FONT-SIZE:18PX;" >  just started to think it was a hardware acceleration problem, but after checking the data, found that Google in 4.0 when the default hardware acceleration is turned on, so the version above should be the same. Later and colleagues study together when found, seems to be animatorset.setduration () method has no effect, and check the source found the following differences:</span>
API 15
/** * Sets the length of each of the "current" child animations of this     animatorset. By default, all child animation would use the its     own duration. If the duration is set to the Animatorset, * then each child     animation inherits this duration.     *     * @param duration The length of the animation, in milliseconds, of each of the child     * animations of this Animat Orset.     */    @Override public    animatorset setduration (long duration) {        if (Duration < 0) {            throw new IllegalArgumentException ("duration must be a value of zero or greater");        }        Just record the value for now-it would be used later when the animatorset starts        mduration = duration;        return this;    }

API 19

    /** * Sets the length of each of the "current" child animations of this     animatorset. By default, all child animation would use the its     own duration. If the duration is set to the Animatorset, * then each child     animation inherits this duration.     *     * @param duration The length of the animation, in milliseconds, of each of the child     * animations of this Animat Orset.     */    @Override public    animatorset setduration (long duration) {        if (Duration < 0) {            throw new IllegalArgumentException ("duration must be a value of zero or greater");        }        for (Node node:mnodes) {            //Todo:don ' t set the duration of the timing-only nodes created by Animatorset to            // Insert "Play-after" delays            node.animation.setDuration (duration);        }        mduration = Duration;        return this;    }


It turns out that the Animatorset.setduration () method on the API15 does not give it a sub-objectanimator setting, The solution, of course, is to set your own duration for each objectanimator that you add to Animatorset.

This is the most typical version of Android compatibility problem, step over the pit and don't do it again.


Android 4.0.x on animatorset.setduration on the pit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.