gpt4 book ai didi

Android ViewPropertyAnimator 不会同时缩放

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:06:45 27 4
gpt4 key购买 nike

每次按下按钮时,我都尝试使用 ViewPropertyAnimator 来缩放 View (不确定的 ProgressBar)。

loadingCircle.animate().scaleY(1.5f).scaleX(1.5f).setDuration(100f);

我有一个 animatorListener 可以缩放回正常的 onAnimationEnd:

loadingCircle.animate().scaleY(1.0f).scaleX(1.0f).setDuration(100f);

没什么太复杂的。但是,它似乎并不总是同时缩放 x 和 y。

通常它第一次就做对了,有时是第二次。当它不起作用时,它只会对链中的最后一个操作进行动画处理。如果它是 scaleX,它只会缩放 X。如果我调换它,它只会缩放 Y。

scaleX 和 scaleY 的文档说:

Animations already running on the property will be canceled

但是,我认为 ViewPropertyAnimator 可以被链接,并且此注释仅适用于新动画(在不同的代码行上)。我做错了什么,还是发现了错误?

我在 GalaxyS4 上运行 Android 4.2.2。库存 ROM,但已 Root 。如果这有所作为。

最佳答案

我相信这确实是一个错误。我通过使用 ObjectAnimator 而不是 ViewPropertyAnimator 来解决这个问题,以获得相同的结果。所以,你的看起来像:

ObjectAnimator animX = ObjectAnimator.ofFloat(loadingCircle, "scaleX", 1.0f);
ObjectAnimator animY = ObjectAnimator.ofFloat(loadingCircle, "scaleY", 1.0f);
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.playTogether(animX, animY);
animSetXY.start();

来源:http://developer.android.com/guide/topics/graphics/prop-animation.html#view-prop-animator

关于Android ViewPropertyAnimator 不会同时缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26024555/

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