Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does ImageSwitcher actually DO?

I'm trying to snaz up my android apps and I see that ImageSwitcher is being referenced a lot for all sorts of animation tasks, but the google docs are totally spartan and don't describe anything other than the methods that are in the class. Meanwhile the examples all make use of gallery, and don't explain why.

Does anyone have a link to (or care to explain) any info on what the class actually does and how it's meant to be used?

like image 238
Yevgeny Simkin Avatar asked Jun 18 '11 20:06

Yevgeny Simkin


1 Answers

I can't give a definitive answer as I've never used it. My best guess comes from working down the inheritance chain...

ViewAnimator...

Base class for a FrameLayout container that will perform animations when switching between its views.

ViewSwitcher

ViewAnimator that switches between two views, and has a factory from which these views are created. You can either use the factory to create the views, or add them yourself. A ViewSwitcher can only have two child views, of which only one is shown at a time.

Then looking at another direct subclass of ViewSwitcher...

TextSwitcher

Specialized ViewSwitcher that contains only children of type TextView. A TextSwitcher is useful to animate a label on screen. Whenever setText(CharSequence) is called, TextSwitcher animates the current text out and animates the new text in.

So reading between the lines, an ImageSwitcher is a ViewAnimator which is optimised for images (i.e., drawables) and as it inherits directly from ViewSwitcher it can only have two images.

So, paraphrasing the TextSwitcher overview, I would say that...

Whenever <insert setImageXXX method here> is called, ImageSwitcher animates the current image out and animates the new image in.

As I said, it's just a 'best guess'.

like image 111
Squonk Avatar answered Oct 13 '22 11:10

Squonk