Android TextView动画无限重复不起作用

Android TextView动画无限重复不起作用,第1张

概述我正在尝试使TextView无限动画.我编写了sequence.xml,它定义了如下所示的动画效果:<setxmlns:android="http://schemas.android.com/apkes/android"android:fillAfter="true"android:interpolator="@android:anim/linear_interpolator"><!

我正在尝试使TextVIEw无限动画.我编写了sequence.xml,它定义了如下所示的动画效果:

<set xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:fillAfter="true"    androID:interpolator="@androID:anim/linear_interpolator" >    <!-- Move -->    <translate        androID:duration="800"        androID:fillAfter="true"        androID:fromXDelta="0%p"        androID:startOffset="300"        androID:toXDelta="2%p" />    <translate        androID:duration="800"        androID:fillAfter="true"        androID:fromXDelta="0%p"        androID:startOffset="1900"        androID:toXDelta="-2%p" /></set>

将此动画分配给TextVIEw的Activity代码如下所示:

TextVIEw tv = new TextVIEw(this);tv.setText(customObject.getText());Animation animsequential;animsequential = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.sequential_horizontal);animsequential.setRepeatMode(Animation.RESTART);animsequential.setRepeatCount(Animation.INFINITE);tv.startAnimation(animsequential);

但这并没有重复动画,而是在第一次迭代结束时停止.如果我有误,请告诉我.

解决方法:

在XML代码中尝试一下. Java代码无法正常工作,因此我很好地解决了这一问题.只需在您的代码中应用此代码即可:

<set xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:shareInterpolator="false" >    <rotate        androID:fromdegrees="0"        androID:pivotX="50%"        androID:pivotY="50%"        androID:todegrees="360"        androID:duration="1000"        androID:repeatCount="infinite"        androID:repeatMode="restart"/></set>

将< rotate>的最后两行相加.在您的代码中.在您的情况下,两个组件中的< translate>并删除等效的Java代码:

animation.setRepeatMode(Animation.INFINITE);animation.setRepeatCount(Animation.INFINITE);

如果有人服务,此代码将使对象无限期地自身旋转.

祝好运!!

总结

以上是内存溢出为你收集整理的Android TextView动画无限重复不起作用全部内容,希望文章能够帮你解决Android TextView动画无限重复不起作用所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1120660.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存