AIDE Tutorial - 46 Blink Animation
Java
package com.kcgroup.animblink;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.view.animation.*;
public class MainActivity extends Activity
{ @Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.main); }
public void blink(View v){
ImageView image=(ImageView)findViewById(R.id.mainImageView);
Animation an=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.blink);
image.startAnimation(an);}}
Main xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
Java
package com.kcgroup.animblink;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.view.animation.*;
public class MainActivity extends Activity
{ @Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.main); }
public void blink(View v){
ImageView image=(ImageView)findViewById(R.id.mainImageView);
Animation an=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.blink);
image.startAnimation(an);}}
Main xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_weight="4"
android:src="@drawable/ic_launcher"
android:id="@+id/mainImageView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:text="Blink"
android:onClick="blink"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
Blink.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
>
<alpha android:fromAlpha="0"
android:toAlpha="1"
android:duration="1000"
android:repeatMode="reverse"
android:repeatCount="2"/>
</set>
Other Related Articles:
android:layout_weight="4"
android:src="@drawable/ic_launcher"
android:id="@+id/mainImageView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:text="Blink"
android:onClick="blink"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
Blink.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
>
<alpha android:fromAlpha="0"
android:toAlpha="1"
android:duration="1000"
android:repeatMode="reverse"
android:repeatCount="2"/>
</set>
Other Related Articles: