I was playing around with Lollipop's Activity Transition.
I have a button in Activity A which when clicked calls Activity B. In the Activity B, I am overriding onBackPressed() and calling finishAfterTransition()
Activity B just has two relative layout blocks with the background color. I have put a shared element transition from the Button to one of the blocks and it works perfectly. Even the return transition works.
But the problem I am having is that I am not able to cancel the shared element return transition and implement a normal exit transition.
The intent was to slide the two blocks off the screen, top one off the top and bottom one off the bottom. That's not working if I have a shared element transition enabled.
I tried setting the exit transition and setting null to sharedElementReturn transition on Activity B. Not working.
I tried setting the reenter transition on Activity A with the slide transition, but still, the shared element transition is reversed on the back press.
If I turn off the shared element transition, the desired effect is perfect on return from Activity B to A.
Any ideas?
Related
I'm unable to set return transition between fragment when back button pressed fragment just closed abruptly without smooth slide out transition, here is what I'm trying:
DetailsFragment.setSharedElementEnterTransition(new DetailsTransition());
DetailsFragment.setReturnTransition(new Slide(Gravity.RIGHT));
According to FlyingNades answer, if you need animation for exiting case you set enter animation to 0 or default animation, like:
fragmentTransaction.setCustomAnimations(0, R.anim.my_exit_animation);
If your fragment still continue to close abruptly, then you may have issue with backstack. You can also give animation for popping from back stack case, like:
fragmentTransaction.setCustomAnimations(0, R.anim.my_exit_animation, 0, R.anim.my_backstack_pop_exit_animation);
I have an activity with a shared element that transitions into another activity. This works fine but the problem is the second activity has some dividers that get drawn on top of the previous activity which looks weird. I saw this video which shows that the enter transition can be delayed until the shared element is placed:
https://www.youtube.com/watch?v=RhiPJByIMrM&index=8&list=WL
Does anyone know how to achieve this?
Thanks.
I have an activity that contain a listview.
My listview has many pictures.
When user touch a picture, second activity start with shared element transition.
Second activity contains viewerpager that shows pictures in first activity.
I want when user press back after change current picture, return transition back to current picture item with animation.
By default sample of shared element transition,when user press back return transition animation back to first item that user touch it.
try use listView.setSelection(position) in onResume method
Or for smooth scroll listView.smoothScrollToPosition(position);
Check this sample project: https://github.com/alexjlockwood/activity-transitions
The key point: you have to tell activity 1 a new position of shared element.
http://1.bp.blogspot.com/-Vv4SxVSI2DY/VEqQxAf3PWI/AAAAAAAAA7c/mfq7XBrIGgo/s400/activity_transitions%2B%281%29.gif
This is a material animation I want to implement, but I can't achieve a similar effect. First of all, the shared element transition moves the image into the second activity. This is quite simple, but then the root layout of the activity starts expanding and during the animation the user can see the first activity until the second activity's view doesn't hide it totally.
I have a main activity that launches another activity, let's call it A2. When A2 finishes loading, it triggers an event that updates the main activity's view. This works great.
The problem is that when I press back or finish() in A2 and it begins the transition animation back to the main activity, the main activity's view doesn't seem to have been redrawn prior to the animation commencing, so as it slides back in it still has the old layout. When the transition finishes, it updates to what it should be.
Is there a way to force the main activity to invalidate its view or otherwise force it to redraw its view prior to the transition, so that the animation looks nice and smooth? I have tried invalidate(), but that does not redraw until after the transition.
(To avoid the XY problem: as a part of a complex animation from the main activity to A2, I create and fade in a black overlay view on the main activity. When A2 onResume()'s, it sends a navigation finished event that causes the main activity to remove the overlay. When returning from A2, that overlay is still rendered, so it looks like it's transitioning into a black screen until the transition finishes and the view re-renders.)