when switching between two activities, screen slides between right to left. When I press back key, screen slides from right to left. Is it a way that when I press back key from an activity to change screen sliding direction?
when switching between two activities, screen slides between right to left. When I press
Share
Danny’s solution could be made to work but it is overly complicated. The key method you want to learn about is overridePendingTransition().
Here is main activity that I mocked up to use it. I made it transition vertically just to show that you can make transformations in any direction you like:
Here is the implementation of the new screen:
Your layout files can be anything you like. You don’t need a wrapper layer. Here is my main.xml:
And here is my new_screen.xml:
The only other things you need are animation XML files that you put in the res/anim folder.
up_in.xml:
up_out.xml:
down_in.xml:
down_out.xml: