Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to make animation TextView android

    • 0
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 307
    Comment on it

    In the below example I have created animation TextView. Here first I have created a animation.xml layout, in animation layoout I have set scale property after then I have added TextView in activity_main.xml and finaly at last In MainActivity I have used AnimationUtils.loadAnimation() method and started the animation with startAnimation() method of target view.See the below code it will clerly describe you how to make animation TextView

    Step(1)-Created animation.xml layout

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/linear_interpolator" android:layout_height="0dp"
        android:layout_width="0dp">
        <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>
    

    Step(2)-activity_main.xml layout-

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:orientation="vertical"
        tools:context=".MainActivity" >
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Rajshekhar"
            android:textStyle="bold|italic"
            android:layout_gravity="center_horizontal" />
    
        <TextView
            android:id="@+id/mytext"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Welcome in Evon"
            android:textStyle="bold"
            android:textSize="28sp"
            android:textAlignment="center"
            android:textColor="#E75555" />
    
    </LinearLayout>
    

    Step(3)MainActivity-

    public class MainActivity extends Activity {
    
        Animation animation;
        TextView myText;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            myText = (TextView) findViewById(R.id.mytext);
    
            animation = AnimationUtils.loadAnimation(this, R.anim.animation);
    
            myText.setOnClickListener(new View.OnClickListener() {
    
                @Override
                public void onClick(View arg0) {
                    myText.startAnimation(animation);
                }
            });
        }
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: