Repeat android animation

后端 未结 4 1676
伪装坚强ぢ
伪装坚强ぢ 2020-12-14 05:39
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.vitesse);

    gpsManager = new GPSManager();

         


        
相关标签:
4条回答
  • 2020-12-14 06:10

    to repeat animation just add the code in xml file which located in anim folder file in which we create a animation object.

    1. android:repeatCount="infinite"
    2. android:repeatMode="restart"
    0 讨论(0)
  • 2020-12-14 06:13
    fadeIn.setRepeatCount(int count)
    
    fadeIn.setRepeatMode(AlphaAnimation.INFINITE(or any other repeat mode reletaed yo your usage)) 
    

    you can use these methods to control repeat.

    implement this if needed

        //anim = your animation 
    
    
    anim.setAnimationListener(new AnimationListener() 
            {
    
                public void onAnimationStart(Animation arg0) 
                {
                    // TODO Auto-generated method stub
    
                }
    
    
                public void onAnimationRepeat(Animation arg0)
                {
                    // TODO Auto-generated method stub
    
                }
    
                public void onAnimationEnd(Animation arg0)
                {
    
    
                }
            });
    

    if you wanna stop your animation suddennly. use yourview.clearAnimation() I hope this helps.

    0 讨论(0)
  • 2020-12-14 06:20

    Like this.

    animation.setRepeatCount(Animation.INFINITE);
    
    0 讨论(0)
  • 2020-12-14 06:26

    Android gives you elegant mechanisms to represent the loading process. You could use an indeterminate ProgressBar, or an ImageView with a scale/alpha animation, instead of animating the TextView itself.

    Maybe you might find this animation useful, for animating alpha and scale at the same time. Vary the parameters for your preference:

    file R.anim.alpha_scale_animation

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android" >
    <scale
        android:fromXScale="0.7"
        android:toXScale="1.0"
        android:fromYScale="0.7"
        android:toYScale="1.0"
        android:pivotX="50%p"
        android:pivotY="50%p"
        android:duration="4000"
        android:repeatCount="infinite"
        />
    
    <alpha
        android:fromAlpha="0.0"
        android:toAlpha="1.0"
        android:duration="2000"
        android:repeatMode="reverse"
        android:repeatCount="infinite"
        />
    </set>
    

    then to launch it in your code:

    Animation connectingAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.alpha_scale_animation);
    myView.startAnimation(connectingAnimation);
    

    And to stop it:

    myView.clearAnimation();
    connectingAnimation.cancel();
    connectingAnimation.reset();
    

    You can also use libraries like ProgressButtonView to have both user interaction and loading process supported in the same widget.

    Hope that any of these solutions result useful to someone :)

    0 讨论(0)
提交回复
热议问题