Build an iOS like Transition on an Activity Change

Viewed 320

So, I'm trying to build a transition between two Activities in my Android App, that looks similar to the transitions in iOS Apps. And my "Going in Transition" works perfectly fine, the way I want it to work, the new layout slides over the old one, while the old one moves just a bit to the left. But now I'm stuck with the reverse transition, going back to my first layout, cause I want it to look exactly like the first transition, but just reversed, which I'm not able to achieve, cause Android automatically layers the moving in transition on top of the moving out transition, as you can see in the attached gif.

So I would have two ideas, to work around that problem. Is there either a possibility to change the layers of the transition? If not, it would be also possible to animate a moving mask ok my moving in transition. But for neither of these possibilities, I know how to implement them.

enter image description here

My current code:

I just call the animations on the OnCreate of my two activities:

OnCreate of my Main Menu:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(R.anim.slide_in_left,R.anim.slide_out_left);
    setContentView(R.layout.activity_main);
}

On Create of my Settings:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(R.anim.slide_in_right,R.anim.slide_out_right);
    setContentView(R.layout.activity_settings);
}

And my xml files: slide_in_left.xml

<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android="http://schemas.android.com/apk/res/android"

android:fromXDelta="-30%p"
android:toXDelta="0"

android:duration="@android:integer/config_longAnimTime" />

slide-out-left.xml

<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android="http://schemas.android.com/apk/res/android"

android:fromXDelta="0"
android:toXDelta="100%p"

android:duration="@android:integer/config_longAnimTime" />

slide_in_right.xml

<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android="http://schemas.android.com/apk/res/android"

android:fromXDelta="100%p"
android:toXDelta="0"

android:duration="@android:integer/config_longAnimTime" />

slide_out_right.xml

<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android="http://schemas.android.com/apk/res/android"

android:fromXDelta="0"
android:toXDelta="-30%p"

android:duration="@android:integer/config_longAnimTime" />
1 Answers
Related