How to add animation to a text view in android

牧云@^-^@ 提交于 2019-12-02 22:36:01

Android TextView Annimation example

XML

<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
      android:fromXScale="1.0"
      android:fromYScale="1.0"
      android:toXScale="2.0"
      android:toYScale="2.0"
      android:duration="3000"></scale>
</set>

Code

private void RunAnimation() 
{
  Animation a = AnimationUtils.loadAnimation(this, R.anim.scale);
  a.reset();
  TextView tv = (TextView) findViewById(R.id.firstTextView);
  tv.clearAnimation();
  tv.startAnimation(a);
}

For More :

http://chiuki.github.io/advanced-android-textview/#/5

http://www.hascode.com/2010/09/playing-around-with-the-android-animation-framework/

You can load animations from AnimationUtils class in Android and set it to a textview in android.

textview.startAnimation(AnimationUtils.loadAnimation(c, android.R.anim.fade_in));

and you can stop animation using,

textview.clearAnimation();

Is your textview id correct?? First check if you are getting your textview id correctly in your app

You need setAnimation in your TextView

Example:

tv.setAnimation( animation ); 

Use Animator/AnimatorSet Animation is legacy code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!