I want to start a new activity with a custom translate animation, so I use overridePendingTransition with my animation in xml.
overridePendingTransition(R.anim.enter_from_right, R.anim.exit_to_left)
enter_from_right.xml:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="100%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="350" />
Is there any way to modify/create an animation programmatically for an activity transition? In this case, modify fromXDelta with an specific value dynamically
I'll answer myself, after doing some research. You need two things:
1 - Create a "transparent" activity by setting the following theme in AndroidManifest. If you don't do this, a blank screen will appear:
2. Create a TranslationAnimation (or the animation you want) manually, applying it to the root decorView, as well as disable the custom animations by setting them to 0:
If you want the reverse animation onBackPressed or when your activity finishes: