res/animation/zoom_in.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="2000"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="3"
android:toYScale="3" >
</scale>
</set>
res/layout/activity_zoom_in.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_in;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zoom_in);
image= (ImageView) findViewById(R.id.image);
btn_Start= (Button) findViewById(R.id.btn_Start);
animationRotate= AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_in);
animationRotate.setAnimationListener(this);
btn_Start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
image.startAnimation(animationZoom_in);
}
});
}
@Override
public void onAnimationEnd(Animation animation) {
if (animation == animationZoom_in) {
}
}
@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="2000"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="3"
android:toYScale="3" >
</scale>
</set>
res/layout/activity_zoom_in.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_in;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zoom_in);
image= (ImageView) findViewById(R.id.image);
btn_Start= (Button) findViewById(R.id.btn_Start);
animationRotate= AnimationUtils.loadAnimation(getApplicationContext(),R.anim.zoom_in);
animationRotate.setAnimationListener(this);
btn_Start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
image.startAnimation(animationZoom_in);
}
});
}
@Override
public void onAnimationEnd(Animation animation) {
if (animation == animationZoom_in) {
}
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
}
No comments:
Post a Comment