Background animation image on ProgressBar on Android?

后端 未结 1 564
灰色年华
灰色年华 2021-02-09 02:54

What is the appropriate action to take when you need to change the background image of a ProgressBar? I mean should use a .gif image like : http://2.bp.blogspot.com/-O7nsXfmg

1条回答
  •  死守一世寂寞
    2021-02-09 03:26

    you need to get all this gif frame image as individual and then set into the animation-list in xml file.

    Here is your anim_progress.xml file code

    
    
        
        
        
        
        
        
        
        
    
    

    set the duration for change as smooth effect for giving animated image like gif

    Here is the code for using this file

    ImageView iv = new ImageView(this);
    iv.setBackgroundResource(R.drawable.anim_progress);
    final AnimationDrawable mailAnimation = (AnimationDrawable) iv.getBackground();
    iv.post(new Runnable() {
        public void run() {
            if ( mailAnimation != null ) mailAnimation.start();
          }
    });
    

    setContentView(iv);

    you can get all frames from gif file from this site.

    http://gif-explode.com/

    for example

    http://2.bp.blogspot.com/-O7nsXfmgwSc/T6PQ0PVr6-I/AAAAAAAAAQI/-eXkEXj24-s/s1600/02.gif

    this link just pass it and you will get all the frame images

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