Tuesday 21 July 2015

Simple way to add animation on Text View


Here is the way to add animation on text view.

create "anim" folder inside res folder.

add text_anim.xml file in it and paste below code -

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
   android:interpolator="@android:anim/linear_interpolator">
   <scale
       android:fromXScale="1.0"
       android:toXScale="0.8"
       android:fromYScale="1.0"
       android:toYScale="1.2"
       android:pivotX="50%"
       android:pivotY="50%"
       android:duration="100"
       android:repeatCount="4"
       android:repeatMode="reverse" />
</set>

now here in your activity class -

TextView tv = (TextView)findViewById(R.id.text);

Animation a = AnimationUtils.loadAnimation(context, R.anim.text_anim);;
tv.startAnimation(a);

Simple Enjoy this cool animation.