{"id":2496,"date":"2017-05-03T07:05:03","date_gmt":"2017-05-03T07:05:03","guid":{"rendered":"http:\/\/webartdevelopers.com\/?p=2496"},"modified":"2017-05-03T07:05:03","modified_gmt":"2017-05-03T07:05:03","slug":"how-to-perform-tween-animationblink-in-android","status":"publish","type":"post","link":"https:\/\/webartdevelopers.com\/blog\/how-to-perform-tween-animationblink-in-android\/","title":{"rendered":"How to Perform Tween Animation(Blink) in Android"},"content":{"rendered":"<p>In this tutorial how to perform Blinking in Tween Animation in Android is shown.<\/p>\n<p>Points to Remember:<\/p>\n<ul>\n<li>For creating the blink.xml file you will have to first create anim folder under res folder.<\/li>\n<li>At the time of creating blink.xml file you can either select &#8216;alpha&#8217; or &#8216;set&#8217; as Root Element.<\/li>\n<\/ul>\n<p>Code:<\/p>\n<p>activity_main.xml<\/p>\n<p>&lt;RelativeLayout xmlns:android=&#8221;http:\/\/schemas.android.com\/apk\/res\/android&#8221;<br \/>\nxmlns:tools=&#8221;http:\/\/schemas.android.com\/tools&#8221;<br \/>\nandroid:layout_width=&#8221;match_parent&#8221;<br \/>\nandroid:layout_height=&#8221;match_parent&#8221;<br \/>\nandroid:paddingBottom=&#8221;@dimen\/activity_vertical_margin&#8221;<br \/>\nandroid:paddingLeft=&#8221;@dimen\/activity_horizontal_margin&#8221;<br \/>\nandroid:paddingRight=&#8221;@dimen\/activity_horizontal_margin&#8221;<br \/>\nandroid:paddingTop=&#8221;@dimen\/activity_vertical_margin&#8221;<br \/>\ntools:context=&#8221;.MainActivity&#8221; &gt;<\/p>\n<p>&lt;ImageView<br \/>\nandroid:id=&#8221;@+id\/imageView1&#8243;<br \/>\nandroid:layout_width=&#8221;wrap_content&#8221;<br \/>\nandroid:layout_height=&#8221;wrap_content&#8221;<br \/>\nandroid:layout_alignParentTop=&#8221;true&#8221;<br \/>\nandroid:layout_centerHorizontal=&#8221;true&#8221;<br \/>\nandroid:src=&#8221;@drawable\/tweenedanm&#8221; \/&gt;<\/p>\n<p>&lt;Button<br \/>\nandroid:id=&#8221;@+id\/b1&#8243;<br \/>\nandroid:layout_width=&#8221;wrap_content&#8221;<br \/>\nandroid:layout_height=&#8221;wrap_content&#8221;<br \/>\nandroid:layout_alignBottom=&#8221;@+id\/imageView1&#8243;<br \/>\nandroid:layout_centerHorizontal=&#8221;true&#8221;<br \/>\nandroid:layout_marginBottom=&#8221;28dp&#8221;<br \/>\nandroid:onClick=&#8221;onBlink&#8221;<br \/>\nandroid:text=&#8221;Blink&#8221; \/&gt;<\/p>\n<p>&lt;\/RelativeLayout&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>res\/anim\/blink.xml<\/p>\n<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;<br \/>\n&lt;set xmlns:android=&#8221;http:\/\/schemas.android.com\/apk\/res\/android&#8221;&gt;<br \/>\n&lt;alpha android:fromAlpha=&#8221;0.0&#8243;<br \/>\nandroid:toAlpha=&#8221;1.0&#8243;<br \/>\nandroid:interpolator=&#8221;@android:anim\/accelerate_interpolator&#8221;<br \/>\nandroid:duration=&#8221;500&#8243;<br \/>\nandroid:repeatMode=&#8221;reverse&#8221;<br \/>\nandroid:repeatCount=&#8221;infinite&#8221;&gt;&lt;\/alpha&gt;<\/p>\n<p>&lt;\/set&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>MainActivity.java<\/p>\n<p>package com.example.demo;<\/p>\n<p>import android.os.Bundle;<br \/>\nimport android.app.Activity;<br \/>\nimport android.view.Menu;<br \/>\nimport android.view.View;<br \/>\nimport android.view.animation.Animation;<br \/>\nimport android.view.animation.AnimationUtils;<br \/>\nimport android.widget.ImageView;<\/p>\n<p>public class MainActivity extends Activity{<\/p>\n<p>ImageView iv;<\/p>\n<p>@Override<br \/>\nprotected void onCreate(Bundle savedInstanceState) {<br \/>\nsuper.onCreate(savedInstanceState);<br \/>\nsetContentView(R.layout.activity_main);<br \/>\niv=(ImageView)findViewById(R.id.imageView1);<br \/>\n}<\/p>\n<p>public void onBlink(View v)<br \/>\n{<br \/>\nAnimation animation=AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink);<br \/>\niv.startAnimation(animation);<br \/>\n}<\/p>\n<p>@Override<br \/>\npublic boolean onCreateOptionsMenu(Menu menu) {<br \/>\n\/\/Inflate the menu; this adds items to the action bar if it is present.<br \/>\ngetMenuInflater().inflate(R.menu.main, menu);<br \/>\nreturn true;<br \/>\n}<br \/>\n}<\/p>\n<p><a href=\"https:\/\/youtu.be\/GMpI70eyH4k\">https:\/\/youtu.be\/GMpI70eyH4k<\/a><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"In this tutorial how to perform Blinking in Tween Animation in Android is shown. Points to Remember: For creating the blink.xml file you will have to first create anim folder under res folder. At the time of creating blink.xml file you can either select &#8216;alpha&#8217; or &#8216;set&#8217; as Root Element. Code: activity_main.xml &lt;RelativeLayout xmlns:android=&#8221;http:\/\/schemas.android.com\/apk\/res\/android&#8221; xmlns:tools=&#8221;http:\/\/schemas.android.com\/tools&#8221; android:layout_width=&#8221;match_parent&#8221; android:layout_height=&#8221;match_parent&#8221; android:paddingBottom=&#8221;@dimen\/activity_vertical_margin&#8221; android:paddingLeft=&#8221;@dimen\/activity_horizontal_margin&#8221; android:paddingRight=&#8221;@dimen\/activity_horizontal_margin&#8221; android:paddingTop=&#8221;@dimen\/activity_vertical_margin&#8221; tools:context=&#8221;.MainActivity&#8221; &gt; &lt;ImageView android:id=&#8221;@+id\/imageView1&#8243; android:layout_width=&#8221;wrap_content&#8221; android:layout_height=&#8221;wrap_content&#8221; android:layout_alignParentTop=&#8221;true&#8221; android:layout_centerHorizontal=&#8221;true&#8221; android:src=&#8221;@drawable\/tweenedanm&#8221; \/&gt; &lt;Button android:id=&#8221;@+id\/b1&#8243; android:layout_width=&#8221;wrap_content&#8221; android:layout_height=&#8221;wrap_content&#8221; android:layout_alignBottom=&#8221;@+id\/imageView1&#8243; android:layout_centerHorizontal=&#8221;true&#8221; android:layout_marginBottom=&#8221;28dp&#8221; android:onClick=&#8221;onBlink&#8221; android:text=&#8221;Blink&#8221; \/&gt; &lt;\/RelativeLayout&gt; &nbsp; res\/anim\/blink.xml &lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt; &lt;set xmlns:android=&#8221;http:\/\/schemas.android.com\/apk\/res\/android&#8221;&gt; &lt;alpha android:fromAlpha=&#8221;0.0&#8243; android:toAlpha=&#8221;1.0&#8243; android:interpolator=&#8221;@android:anim\/accelerate_interpolator&#8221; android:duration=&#8221;500&#8243; android:repeatMode=&#8221;reverse&#8221; android:repeatCount=&#8221;infinite&#8221;&gt;&lt;\/alpha&gt; &lt;\/set&gt; &nbsp; MainActivity.java package com.example.demo; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ImageView; public class MainActivity extends Activity{ <!-- AddThis Advanced Settings generic via filter on get_the_excerpt -->","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62],"tags":[95,94],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2496"}],"collection":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/comments?post=2496"}],"version-history":[{"count":2,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2496\/revisions"}],"predecessor-version":[{"id":2498,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2496\/revisions\/2498"}],"wp:attachment":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/media?parent=2496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/categories?post=2496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/tags?post=2496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}