How To Add Animation To A Text View In Android
I have a TextView and I'm trying to add a fade in animation to it. My code is returning null and I don't understand why. Here is my implementation This is the fade_in.xml
Solution 1:
Android TextView Annimation example
XML
<?xml version="1.0" encoding="utf-8"?><setxmlns:android="http://schemas.android.com/apk/res/android"><scaleandroid:fromXScale="1.0"android:fromYScale="1.0"android:toXScale="2.0"android:toYScale="2.0"android:duration="3000"></scale></set>
Code
privatevoidRunAnimation()
{
Animationa= AnimationUtils.loadAnimation(this, R.anim.scale);
a.reset();
TextViewtv= (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/
Solution 2:
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();
Solution 3:
Is your textview id correct?? First check if you are getting your textview id correctly in your app
Solution 4:
You need setAnimation in your TextView
Example:
tv.setAnimation( animation );
Solution 5:
Use Animator/AnimatorSet Animation is legacy code
Post a Comment for "How To Add Animation To A Text View In Android"