ImageSwitcher 实际上是做什么的?

发布于 2024-11-16 00:12:03 字数 172 浏览 3 评论 0原文

我正在尝试快速启动我的 Android 应用程序,我发现 ImageSwitcher 在各种动画任务中被大量引用,但 google 文档完全简明扼要,除了类中的方法之外,没有描述任何其他内容。同时这些例子都使用了gallery,并且没有解释为什么。

有没有人有链接(或愿意解释)有关该类实际用途及其用途的任何信息?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

呆头 2024-11-23 00:12:03

我无法给出明确的答案,因为我从未使用过它。我最好的猜测来自于继承链的工作...

ViewAnimator...

FrameLayout 容器的基类,它将在视图之间切换时执行动画。

视图切换器

ViewAnimator 在两个视图之间切换,并有一个用于创建这些视图的工厂。您可以使用工厂来创建视图,也可以自己添加它们。一个 ViewSwitcher 只能有两个子视图,其中一次只显示一个。

然后查看 ViewSwitcher 的另一个直接子类...

文本切换器

仅包含 TextView 类型子级的专用 ViewSwitcher。 TextSwitcher 对于在屏幕上制作标签动画很有用。 每当调用 setText(CharSequence) 时,TextSwitcher 都会以动画方式输出当前文本并以动画方式输入新文本。

因此,从字里行间看,ImageSwitcher 是一个 ViewAnimator< /code> 它针对图像(即可绘制对象)进行了优化,并且由于它直接继承自 ViewSwitcher 它只能有两个图像。

因此,解释一下 TextSwitcher 概述,我想说...

每当 被调用时,ImageSwitcher 都会将当前图像动画化并动画化 。

正如我所说,这只是一个“最佳猜测”

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'.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文