Reprint please indicate the source: Wang 亟亟 's way of Daniel
This control before the general and see the V1 version, and then sat and did the update, and wrote the analysis of the blog, that this side of the simple to put the content of the introduction to everyone is good (and help me Easy)
First look at the effect of the operation:
The content is hand-painted, can see the original author's deep skill, 666666
This way, how to use it?
The original author wants the control to be stored under ImageView or view, so this
ImageView.setImageDrawable(new LoadingDrawable(new GearLoadingRenderer(Context))); ImageView.setImageDrawable(new LoadingDrawable(new WhorlLoadingRenderer(Context))); ImageView.setImageDrawable(new LoadingDrawable(new LevelLoadingRenderer(Context))); ImageView.setImageDrawable(new LoadingDrawable(new MaterialLoadingRenderer(Context)));
Or so
View.setBackground(new LoadingDrawable(new GearLoadingRenderer(Context))); View.setBackground(new LoadingDrawable(new WhorlLoadingRenderer(Context))); View.setBackground(new LoadingDrawable(new LevelLoadingRenderer(Context))); View.setBackground(new LoadingDrawable(new MaterialLoadingRenderer(Context)));
Of course, if you want to manipulate the object, it is more recommended to pass in the class variable, rather than just throw it in the new one, like this
privateprivate LoadingDrawable mElectricFanDrawable;
First define a Loadingdrawable object, a ImageView object
new LoadingDrawable(new ElectricFanLoadingRenderer(this));
Then give the image object an initialization operation (this is the first yellow control to do the demo)
mIvElectricFan.setImageDrawable(mElectricFanDrawable);
and pass the image on to ImageView.
How do I turn the animation off?
mElectricFanDrawable.start();//开启 mElectricFanDrawable.stop();//关闭
More nutritious analysis of the part has been posted below, want to learn the boy can see, want to directly use the above these enough
Source: Https://github.com/dinuscxj/LoadingDrawable/archive/master.zip
Analysis article: HTTP://WWW.JIANSHU.COM/P/1C3C6FC1B7FF
Flipping through git---practical progress class custom control loadingdrawable