可以直接跳到ViewAnimator中的第二个视图 [英] Possible to jump straight to second view in ViewAnimator

查看:79
本文介绍了可以直接跳到ViewAnimator中的第二个视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ViewAnimator(准确地说是ViewSwitcher),它带有淡入淡出动画,还有两个Views,我可以在两个Views之间使用ViewAnimator.showNext()ViewAnimator.showPrevious()方法进行过渡.

I have a ViewAnimator (ViewSwitcher to be precise) with fade in/out animations associated to it and two Views which I transition between using the ViewAnimator.showNext() and ViewAnimator.showPrevious() methods.

我的应用程序中有一个要求,有时我需要直接从第二个View开始,而在从第一个View到第二个View时不显示淡入淡出的动画.有人知道是否有一种简单的方法可以完成此任务,而不必弄乱与我的ViewAnimator相关的输入/输出动画吗?

There is a requirement in my app where sometimes I need to start straight from the second View, without showing a fade animation in going from the first View to the second. Anyone know if there is a straightforward way to accomplish this without having to mess around with the in/out animations associated to my ViewAnimator?

注意::我尝试调用ViewAnimator.setDisplayedChild(1),但这也可以为过渡设置动画效果.

Note: I have tried calling ViewAnimator.setDisplayedChild(1) but that also animates the transition.

推荐答案

我环顾四周,等待响应,但我猜不可能.因此,在没有更好的解决方案的情况下,当您想直接跳转到ViewAnimator的特定子View时,请将ViewAnimator的输入/输出动画设置为null,如下所示:

I looked around and waited for a response but I'm guessing it's not possible. So, in the absence of a better solution, set your ViewAnimator's in/out animations to null when you want to jump straight to a particular child View of your ViewAnimator, as follows:

myViewAnimator.setInAnimation(null);
myViewAnimator.setOutAnimation(null);
myViewAnimator.setDisplayedChild(childIndex);

如果有人知道更好的方法-而不是玩ViewAnimator的输入/输出动画-请分享!

If anyone knows a better way - rather than playing with the ViewAnimator's in/out animations - please share!

这篇关于可以直接跳到ViewAnimator中的第二个视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆