我有一个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中的第二个视图
发布评论