In my app i have a custom progress bar
progress.xml
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();`