I have made an activity in android,I want is when i start the app the very first activity in my app should come from left and slide to right animation effect.but i have no idea about how to implement it,So can anyone help me or give me some trick so that i can solve it out.I have animation XML ready with my project.
Thank you in advance my code:
package com.esp.Estorec.ui;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.RelativeLayout;
public class SplashActivity1 extends Activity implements AnimationListener {
RelativeLayout view;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
view=(RelativeLayout)findViewById(R.id.splash1);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash1);
Animation animationSlideInLeft = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);
animationSlideInLeft.setAnimationListener(new AnimationListener(){
@Override
public void onAnimationEnd(Animation animation) {
// if you need to do something
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationStart(Animation animation) {
}});
view.startAnimation(animationSlideInLeft);
new Handler().postDelayed(new Runnable()
{
@Override
public void run()
{
handler.sendEmptyMessage(1);
}
}, 2000);
}
private Handler handler = new Handler()
{
@SuppressWarnings("deprecation")
@Override
public void handleMessage(android.os.Message msg)
{
try
{
Intent intent = null;
intent = new Intent(SplashActivity1.this,
SplashActivity2.class);
startActivity(intent);
overridePendingTransition(R.anim.animated_activity_slide_left_in, R.anim.animated_activity_slide_right_out);
finish();
} catch (Exception e) {
}
}
};
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
}