res/animation/zoom_out.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.5"
android:toYScale="0.5" >
</scale>
</set>
res/layout/activity_zoom_out.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher/>
<Button android:id="@+id/btn_Start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start Animation/>
</RelativeLayout>
MainActivity.java
package example.animations;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
public class MainActivity extends Activity implements AnimationListener {
ImageView image;
Button btn_Start;
Animation animationZoom_out;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zoom_out);
image= (ImageView) findViewById(R.id.image);
btn_Start= (Button) findViewById(R.id.btn_Start);
animationRotate= AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out);
animationRotate.setAnimationListener(this);
btn_Start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
image.startAnimation(animationZoom_out);
}
});
}
@Override
public void onAnimationEnd(Animation animation) {
if (animation == animationZoom_out) {
}
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
}
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.5"
android:toYScale="0.5" >
</scale>
</set>
res/layout/activity_zoom_out.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher/>
<Button android:id="@+id/btn_Start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start Animation/>
</RelativeLayout>
MainActivity.java
package example.animations;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
public class MainActivity extends Activity implements AnimationListener {
ImageView image;
Button btn_Start;
Animation animationZoom_out;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zoom_out);
image= (ImageView) findViewById(R.id.image);
btn_Start= (Button) findViewById(R.id.btn_Start);
animationRotate= AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_out);
animationRotate.setAnimationListener(this);
btn_Start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
image.startAnimation(animationZoom_out);
}
});
}
@Override
public void onAnimationEnd(Animation animation) {
if (animation == animationZoom_out) {
}
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
}