What does ImageSwitcher really do?

I'm trying to hack my android apps and I see that ImageSwitcher often refers to all kinds of animation tasks, but google docs are completely spartan and don't describe anything other than the methods that are in the class. Meanwhile, all examples use the gallery and do not explain why.

Does anyone have a link to (or to explain) any information about what the class really does and how it should be used?

+6
source share
1 answer

I cannot give a definitive answer, since I have never used it. My best guess is working on an inheritance chain ...

ViewAnimator ...

The base class for the FrameLayout container that will perform the animation when switching between its views.

ViewSwitcher

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

Then, looking at another direct subclass of ViewSwitcher ...

Textswitcher

A specialized ViewSwitcher containing only children of type TextView. TextSwitcher is useful for animating a shortcut on the screen. When setText (CharSequence) is called, TextSwitcher animates the current text and animates the new text.

Thus, for reading between lines, ImageSwitcher is a ViewAnimator that is optimized for images (i.e. drawables) and, since it inherits directly from ViewSwitcher , it can only have two images.

So, to paraphrase the TextSwitcher review, I would say that ...

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

As I said, this is simply a โ€œbest guessโ€.

+7
source

Source: https://habr.com/ru/post/890825/


All Articles