gpt4 book ai didi

Android - 使用 ObjectAnimator 的移动按钮不起作用

转载 作者:行者123 更新时间:2023-11-30 03:45:06 26 4
gpt4 key购买 nike

我需要将按钮从一个位置移动到另一个位置。 View 位置移动工作正常,但只有旧区域是可点击的。

这是我的代码:

 Button animatorButton = (Button)findViewById(R.id.animatorbutton);
ObjectAnimator objectAnimatorButton = ObjectAnimator.ofFloat(animatorButton, "translationX", 0f, 400f);
objectAnimatorButton.setDuration(1000);
objectAnimatorButton.start();

如何移动按钮以禁用旧的可点击区域?

最佳答案

你用的是什么安卓版本?在 3.0 之前,您需要在动画完成后手动移动 View 才能移动可点击区域。请参阅此回复作为引用”How to do interactive animation (translation) with Android

在 3.0 和更新版本中,PropertyAnimator 也会移动可点击区域。您是否在 pre 3.0 设备上使用 nineoldandroid 动画包?如果是这样,您将只能看到 View 动画的效果,而看不到属性(又名可点击区域)移动的完整效果。

关于Android - 使用 ObjectAnimator 的移动按钮不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15132980/

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