I have a viewpager with 5-6 fragments in it. Each fragment is of the same class and contains an imageView. I am trying to show an animation drawable in the imageView. The imageView is being shown empty in first two fragments initially (as only those are cached by pager) once i scroll to 4 fragment and scroll back all fragments show the images being animated.
imgView.setBackgroundDrawable(animationDrawable);
imgView.post(new Runnable() {
@Override
public void run() {
animationDrawable.start();
}
});