Android Animation Animationset encountered a problem.

Source: Internet
Author: User

Before the Android animation this block has been smattering, know a ballpark, and will not be used. Just these days there are not too many tasks to do, you can comb some knowledge of Android animation. The basic usage of Android animation is not said, here is mainly recorded in the simple practical problems encountered.

Some of the properties of Animationset in 1.XML have some problems.

The main thing is android:repeatcount,android:repeatmode invalid. The problem is said to be deliberately by Google's engineers. "Reference: Http://stackoverflow.com/questions/4480652/android-animation-does-not-repeat".

However, there are some remedial measures, such as the ability to set Animationlistener for animation. Then in the Onanimationend () method, start the animation again.

2.AnimationSet animation to add order problems.

Since the animations added by the Animationset addanimation () method are processed in terms of the order in which the animations are added, it is assumed that there is a series of animations (not just one transform position) acting on a to make a convert B, So if you want to make B into the previous a by another series of animations, it's best to ensure that the animation is in the same order as before and after two conversions. Compared to the film image has been animated: A,b,c transform into Image2, if you want to transform from image2 to image, then the order of animation also need to a,b,c (of course, this premise is to have a number of possible changes in the position of the animation)

For example: Define animations in XML: First ronate, then alpha, then scale, and finally translate.

<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android"     android:re    >    <rotate        android:duration= "+"        android:fromdegrees= "0"        android: pivotx= "50%"        android:pivoty= "50%"        android:todegrees= ">"    </rotate>    <alpha        android:duration= "android:fromalpha="        1.0 "        android:startoffset=" 0 "        android:toalpha=" 0.5 "/ >    <scale        android:duration= "android:fromxscale="        1.0 "        android:fromyscale=" 1.0 "        android:pivotx= "50%"        android:pivoty= "50%"        android:toxscale= "4"        android:toyscale= "4" >    </scale>    <translate        android:duration= "android:fromxdelta="        0 "        android: Fromydelta= "0"        android:toxdelta= " -100"        android:toydelta= " -800" >    </translate></set >

If you need to restore an animation, you need to:

Alphaanimation alphaanimation = new Alphaanimation (0.5f, 1.0f); Rotateanimation rotateanimation = new Rotateanimation (360f, 0f,                animation.relative_to_self, 0.5f, Animation.relative_to_self, 0.5f); Scaleanimation scaleanimation = new Scaleanimation (4.0f, 1.0f,4.0f, 1.0f, Animation.relative_to_self, 0.5f, Animation.relative_to_self, 0.5f); Translateanimation translateanimation = new Translateanimation (animation.absolute, -100,animation.absolute, 0, Animation.absolute, -800,animation.absolute, 0); Animationset set = new Animationset (true); Set.setinterpolator (new Acceleratedecelerateinterpolator ()); Set.addanimation (alphaanimation); set.addanimation (scaleanimation); set.addanimation (rotateAnimation); Set.addanimation (translateanimation); set.setduration (3000);

Otherwise it may be in the process of conversion, the animation is not smooth, flashing phenomenon.

Android Animation Animationset encountered a problem.

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.