Animation xml files:
right_slide_in.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
  
<translate
android:fromXDelta="100%p"
android:toXDelta="0"
android:duration="300"/>
</set>
left_slide_out.xml:
    
left_side_out.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="0"
android:toXDelta="-100%p"
android:duration="300"/>
</set>
right_slide_out.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<translate
android:fromXDelta="0"
android:toXDelta="100%p"
android:duration="300"
/>
</set>
   
         
    
right_slide_in.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<translate
android:fromXDelta="100%p"
android:toXDelta="0"
android:duration="300"/>
</set>
left_slide_out.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
         android:fromXDelta="0" 
         android:toXDelta="-100%p" 
         android:duration="300"/>
</set>
left_side_out.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="0"
android:toXDelta="-100%p"
android:duration="300"/>
</set>
right_slide_out.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<translate
android:fromXDelta="0"
android:toXDelta="100%p"
android:duration="300"
/>
</set>
FirstActivity.java
    Button b_next = (Button)findViewById(R.id.button1);
    b_next.setOnClickListener(new OnClickListener() {
   @Override
    public void onClick(View arg0) {
   // TODO Auto-generated method stub
                    Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
                    startActivity(intent);
                    overridePendingTransition(R.anim.right_slide_in, R.anim.left_side_out);
                    FirstActivity.this.finish(); 
  }
     });
SecondActivity.java
Button button_previous = (Button)findViewById(R.id.button2);
button_previous .setOnClickListener(new OnClickListener() {
   
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
  
Intent intent = new Intent(SecondActivity.this, FirstActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.left_side_in, R.anim.right_slide_out);
SecondActivity.this.finish();
}
});
Click here to Download full Source Code
SecondActivity.java
Button button_previous = (Button)findViewById(R.id.button2);
button_previous .setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(SecondActivity.this, FirstActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.left_side_in, R.anim.right_slide_out);
SecondActivity.this.finish();
}
});
Click here to Download full Source Code
 
It very nice tutorial thank you Dear
ReplyDeleteVery useful code, please do update with more tutorials
ReplyDeleteIt very nice tutorial thank you
ReplyDelete