Android: repeatcount = "infinite" is invalid in Set

Source: Internet
Author: User

XML is as follows:

<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"    android:repeatCount="infinite"    android:repeatMode="restart">      <alpha          android:fromAlpha="0.0"          android:toAlpha="1.0"          android:duration="1000"/>      <alpha        android:startOffset="3000"        android:fromAlpha="1.0"          android:toAlpha="0.0"          android:duration="1000"/></set>

The function originally intended to be implemented is to make the transparency from 0 to 1, wait for 2 seconds, and then let the transparency from 1 to 0 to achieve the goal of flashing; the advantage of doing so is that you can control the display time;

Some people say that setrepeatcount (animation. infinite); you can do it. It is best to set the animationlistener to repeat the onanimationend event.

Animation anim = AnimationUtils.loadAnimation(BuzzFinderActivity.this, R.anim.crosshair_focusing);            anim.setAnimationListener(new AnimationListener() {                @Override                public void onAnimationEnd(Animation arg0) {                    Animation anim = AnimationUtils.loadAnimation(BuzzFinderActivity.this, R.anim.crosshair_focusing);                    anim.setAnimationListener(this);                    brackets.startAnimation(anim);                }                @Override                public void onAnimationRepeat(Animation arg0) {                    // TODO Auto-generated method stub                }                @Override                public void onAnimationStart(Animation arg0) {                    // TODO Auto-generated method stub                }            });

Certificate -------------------------------------------------------------------------------------------------------------------------------------

Digress:

Although only the Alpha animation is used, the following settings can also achieve the flickering effect, but the display time is not well controlled. If you want to make the time of the gradient inconsistent, it will be even worse.

Alpha. setrepeatcount (animation. Infinite );

Alpha. setrepeatmode (animation. Reverse );

Certificate -------------------------------------------------------------------------------------------------------------------------------------

Discussion: http://stackoverflow.com/questions/4480652/android-animation-does-not-repeat

Related Article

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.