res/animation/slide_down.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<scale
android:duration="1000"
android:fromXScale="1.0"
android:fromYScale="0.0"
android:toXScale="1.0"
android:toYScale="1.0" />
</set>
res/layout/activity_slide_down.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 animationSlide_down;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_slide_down);
image= (ImageView) findViewById(R.id.image);
btn_Start= (Button) findViewById(R.id.btn_Start);
animationRotate= AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slide_down);
animationRotate.setAnimationListener(this);
btn_Start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
image.startAnimation(animationSlide_down);
}
});
}
@Override
public void onAnimationEnd(Animation animation) {
if (animation == animationSlide_down) {
}
}
@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
android:duration="1000"
android:fromXScale="1.0"
android:fromYScale="0.0"
android:toXScale="1.0"
android:toYScale="1.0" />
</set>
res/layout/activity_slide_down.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 animationSlide_down;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_slide_down);
image= (ImageView) findViewById(R.id.image);
btn_Start= (Button) findViewById(R.id.btn_Start);
animationRotate= AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slide_down);
animationRotate.setAnimationListener(this);
btn_Start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
image.startAnimation(animationSlide_down);
}
});
}
@Override
public void onAnimationEnd(Animation animation) {
if (animation == animationSlide_down) {
}
}
@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