避免动画自动“展开”?

发布于 2025-01-05 19:34:03 字数 856 浏览 5 评论 0 原文

我有一个简单的视图动画,但我看不到“摆脱”动画“展开”(而且我似乎无法在网上找到解决方案)。

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
  android:interpolator="@android:anim/linear_interpolator"
  android:shareInterpolator="true" >

  <scale
    android:duration="250"
    android:fromXScale="1"
    android:fromYScale="1"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="0"
    android:toXScale="1.1"
    android:toYScale="1.1" />

</set>

简而言之,它的作用是从中间按比例将视图膨胀 10%。

但是,当它执行时,它会膨胀,而当它到达末尾时,它又会收缩。 我想避免这种情况——“放松”效应——当它从 110% 缩小到 100% 时。 那怎么办呢?

编辑:

我简单地以此开始:

Animation animation1 = AnimationUtils.loadAnimation(this, R.anim.<name>);
v.startAnimation(animation1);

I've a simple view animation, but I can't see to get "rid" of the animation "unwinding" (and I can't seem to find a solution online).

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
  android:interpolator="@android:anim/linear_interpolator"
  android:shareInterpolator="true" >

  <scale
    android:duration="250"
    android:fromXScale="1"
    android:fromYScale="1"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="0"
    android:toXScale="1.1"
    android:toYScale="1.1" />

</set>

What this does is, simply, inflates the View by 10% proportionally, from the middle.

But, when it executes, it inflates and, when it reaches the end, it deflates back. I want to avoid that -- the "unwinding" effect -- when it scales back from 110% to 100%.
How can that be done?

Edit:

I'm starting it simply with this:

Animation animation1 = AnimationUtils.loadAnimation(this, R.anim.<name>);
v.startAnimation(animation1);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如梦亦如幻 2025-01-12 19:34:03

正确的答案可以在这里找到:如何在 Android 中对视图进行动画处理并让它保持在新的位置/大小?

它将:放在

  android:fillAfter="true"
  android:fillEnabled="true"

标记内。

The correct answer is found here: How can I animate a view in Android and have it stay in the new position/size?

It is putting this:

  android:fillAfter="true"
  android:fillEnabled="true"

inside the <set tag.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文