Android custom progress bar with .gif file

后端 未结 6 1902
执念已碎
执念已碎 2020-12-20 04:05

In my app i have a custom progress bar

progress.xml

 

        
6条回答
  •  攒了一身酷
    2020-12-20 04:59

    • First Conver your Gif image to png Slice image sequence.

    • Declare Your Progress bar as Image view.

       
      
    • Create .xml file in drawable folder using your .png sequence image those are generated from gif. In this case, Loading_web_animation.xml

       
           
       
       
       
       
       
       
       
       
       
       
       
       
       
      
    • In Main Activity set the code like,

       private AnimationDrawable animationDrawable;
       private ImageView mProgressBar;
       mProgressBar.setBackgroundResource(R.drawable.loading_web_animation);
       animationDrawable = (AnimationDrawable)mProgressBar.getBackground();
       mProgressBar.setVisibility(View.VISIBLE);
       animationDrawable.start();
       mProgressBar.setVisibility(View.GONE);
       animationDrawable.stop();`
      

提交回复
热议问题