[embedyt] https://www.youtube.com/watch?v=otMSB-dFuY8[/embedyt]
Links & Dependenciesactivity_main.xmlMainActivity.java
Library on GitHub with installation instructions:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.codinginflow.androidviewanimationsexample.MainActivity"> <TextView android:id="@+id/text_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="Hello World!" android:textSize="30sp" /> <Button android:id="@+id/button_animate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="47dp" android:text="animate" /> </RelativeLayout>
package com.codinginflow.androidviewanimationsexample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; import com.daimajia.androidanimations.library.Techniques; import com.daimajia.androidanimations.library.YoYo; public class MainActivity extends AppCompatActivity { private TextView mTextView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTextView = findViewById(R.id.text_view); Button buttonAnimate = findViewById(R.id.button_animate); buttonAnimate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { YoYo.with(Techniques.Tada) .duration(700) .repeat(1) .playOn(mTextView); } }); } }