gpt4 book ai didi

android - 具有 'huge' 延迟的 ViewFlipper

转载 作者:塔克拉玛干 更新时间:2023-11-02 18:58:42 24 4
gpt4 key购买 nike

我有一个 ViewFlipper,它在调用 showPrevious 时运行 View 动画。动画效果很好。但问题是它以超过 1 秒的延迟开始。现在这看起来没什么,但它会严重延迟应用程序的使用。

我的动画是这样的;

Animation inFromLeft = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, -1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
inFromLeft.setDuration(350);
inFromLeft.setInterpolator(new LinearInterpolator());

Animation outtoRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, +1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
outtoRight.setDuration(350);
outtoRight.setInterpolator(new LinearInterpolator());

我使用 setInAnimationsetOutAnimation 设置动画;

setInAnimation(inFromLeft);
setOutAnimation(outtoRight);

然后我使用 showPrevious 启动动画

是否有任何原因导致动画开始延迟超过 1 秒,动画的 startTime 为 -1 且 startOffset 为 0。

最佳答案

两个建议。首先,如果可能,改用 ViewPager。其次,如果第一个不可能,则使用基于 XML 的动画。将内容从代码中推送到资源中通常是一种胜利。

关于android - 具有 'huge' 延迟的 ViewFlipper,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11953533/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com