In this tutorial we will see a simple animation to an imageview which allows the imageview to blink in certain duration. Let us start by adding imageview to your layout.
<ImageView android:id="@+id/im_blink" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:background="@drawable/android"/>
Now simply add the following code to your Activity class file
ImageView im_blink = (ImageView) findViewById(R.id.im_blink); final Animation animation = new AlphaAnimation((float) 0.5, 0); animation.setDuration(500); animation.setInterpolator(new LinearInterpolator()); animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.REVERSE); im_blink.startAnimation(animation);
Note: You need to have a png image in your drawable folder which is referring in the above layout
