gpt4 book ai didi

android - android中的动画轮效果

转载 作者:行者123 更新时间:2023-11-29 19:46:17 26 4
gpt4 key购买 nike

有什么方法可以像这样在 Android 中的按钮后面创建射线动画 https://davidwalsh.name/javascript-spin

它应该只是在硬币后面旋转。

like this pic

光线应该在父布局的矩形内旋转。有什么简单的方法吗?

我的代码:

final Animation animRotate = AnimationUtils.loadAnimation(context,R.anim.image_rotate);

ImageView rl2=(ImageView) view.findViewById(R.id.ss);

rl2.startAnimation(animRotate);

and xml file:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:duration="10000"
android:repeatMode="restart"
android:repeatCount="-1"
android:pivotX="50%"
android:pivotY="50%">
</rotate>
</set>

最佳答案

您可以使用 objectAnimator 来实现这一点。

<objectAnimator
android:duration="3000"
android:propertyName="rotation"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:valueTo="360"
android:valueType="floatType" />

还有一件事 accelerate_decelerate_interpolator 使动画在开始时加速并在结束时减速。

关于android - android中的动画轮效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37568189/

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