Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animation Transitions during Move from One Activity to Another Activity in Android

Tags:

android

I need a Animation transitions when change from one activity another activity in android. The transition like a sliding tabs.

like image 417
Santhosh Kumar S Avatar asked Sep 25 '22 13:09

Santhosh Kumar S


2 Answers

Step 1:create animation files in resources anim directory.

pull_in_left.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="300"
    android:fromXDelta="-100%"
    android:toXDelta="0%"
    android:interpolator="@android:anim/decelerate_interpolator"
     />

pull_in_right.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="300"
    android:fromXDelta="100%"
    android:toXDelta="0%"
    android:interpolator="@android:anim/decelerate_interpolator"
     />

push_out_left.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="300"
    android:fromXDelta="0%"
    android:interpolator="@android:anim/decelerate_interpolator"
    android:toXDelta="-100%" />

push_out_right.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="300"
    android:fromXDelta="0%"
    android:interpolator="@android:anim/decelerate_interpolator"
    android:toXDelta="100%" />

Step 2: Implement animation on activity.

Intent intent = new Intent(mContext, NextActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.pull_in_left, R.anim.push_out_right);
like image 174
Vishal Patoliya ツ Avatar answered Oct 11 '22 03:10

Vishal Patoliya ツ


This may be help you

overridePendingTransition(R.anim.pull_in_from_left, R.anim.hold);

Animation file for pull_in_from_left

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromXDelta="-100%"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="0%" /> 

You can Modify the fromXDeltaand toXDelta value for Direction Changes.

like image 43
Gopal Avatar answered Oct 11 '22 03:10

Gopal