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.)
Related
I have an activity with the bottom navigation menu.
I want to make it when I press the middle button on the menu, a small fragment pops up (doesn't fill the whole screen) and the rest of the screen gets a little bit darker and every touch that occurs outside of the small fragment I created will not be recognized as a touch in the other background fragment but instead will destroy the small fragment.
I created the small fragment and called detach and attach to the background fragment when I create and destroy the small one. However, it doesn't call the onPause and onResume functions in the fragments so it doesn't work. Also, I don't know how to make it that if I press outside of the fragment, it gets destroyed.
Can anyone help me?
That's what I'm trying to achieve:
How can i keep an animation alive while the transitions between activities are occurring?
Suppose that i have two activities A and B. Activity B has a "slide in" transition over the activity A. I want to keep a button rotating in my activity A while the transition of B is occurring. My button stop the rotating animation when the Activity B starts the slide over the activity A. I guess it happens because the android switch the UI Thread process to the new activity that is coming and stop what the previous activity was doing, but in my case the user still can see the activity A being covered by the activity B.
Activity B starts and pushes Activity A to the left. This transition takes 200ms and I implement this calling this method in onCreate() before setContentView()
overridePendingTransition(R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left);
What I want to achieve is to start animating UI elements in the contentView at 100ms...So that the whole animation has a continuous feel. I haven't found where in the code I should start animating the UI elements.
I know you should use services, backgroundtasks and AsynTask for long running processes. I've also seen this and this.
is there any way to start a activity in background and when process finishes, change the activity to current activity?
Suppose I have two activity A and B.
When user clicks on a view(a item in bottom navbar for example) on activity A, the desired action is to animate that view then start activity B.
But the problem is that there is a lag between animation terminate and starting of Activity B.
What I'm thinking of is to setup activity B while the view in activity A is animating.
As soon as animation terminates the activities swipe smoothly.
Is there a possible solution for this?
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?