可以直接跳到ViewAnimator中的第二个视图 [英] Possible to jump straight to second view in 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屋!