Delay enter transition animation until shared element placement - android

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.

Related

Prevent last Fragment from being removed from backstack

I am currently writing a drawer layout as my main layout, with an embedded FrameLayout that I will be using to hold each “page” when an item on the drawer is clicked on. When the app first starts, an initial fragment will be show. Other fragments may be added/replaced later which is fine, however, my problem is that when the user clicks the back button on the very first “initial fragment”, I don’t want that particular fragment to be removed from the layout. Currently, it is being removed and it’s just showing a drawer layout with no other content (which makes sense). I want the app to automatically exit if the initial fragment was the last one showing and the back button is pressed, instead of removing that initial fragment and then after another back press, then it exits.
Things I have thought of doing:
Not adding the first fragment to the backstack. (If I do this, I can compare it with the classname of the fragment which is a somewhat longer string, or I can use a boolean value for once the first fragment has been placed (and not added to backstack), the boolean is set which allows the fragments to now be added.
Overriding the onBackPressed function of the activity
Does anyone have a suggested way of doing this or can think of a better way? Thanks
The first bullet point sounds the cleanest. You have no other need to handle conditions when back is hit, correct? If that's the case, it's less lines of code (removing one as opposed to adding several) and you get to keep default Activity methods as is.
I know that's not exactly what you asked, but I think the first bullet point is so clean, that I just wouldn't try something else.
I have implemented same in one of the app using my own Stack of fragment. and also implemented onBackPressed method.
Every time when user clicks on item in drawer i add fragment in stack and in back press once its length is 1 I finish the activity with message.
On item click -- Add/replace fragment in container.
OnBackPressed -- Pop fragments from stack and once its last one i finish activity.
Hope this can give you another option to consider.

How to return different shared element from first shared element when start a transition activity

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.

How to create a transition like this one?

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.

Slide in animation immediately after shared element transition is done

I have two main activities - a list view (using the RecyclerView), and a detailed page. Each item in the list has a small image, and when clicking on an item in the list, I have an animation (using a shared element transition) that makes the image larger, and it takes up the upper half of the screen.
The bottom half of the detailed activity, has many details in various layouts.
My problem is that during the shared element transition of the image, I see all the details just appearing on the overlay.
I would like for the detailed activity to wait for the shared element transition to finish, and then slide in the details from the bottom of the page.
I searched the internet for this, but all the posts I found on the subject are either too old, or don't have enough details, so I couldn't get them to work.
Things I tried already :
In the detailed view, in onCreate() I tried creating a TransitionSet object with a delayed slide transition, and call getContentTransitionManager().beginDelayedTransition(). This didn't seem to do anything.
Creating the same TransitionSet object and calling getWindow().setEnterTransition(myTransitionSet) but this also doesn't seem to work.
I have defined getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS); in the beginning of the onCreate() method in the detailed activity.
I'm sure I'm just missing something, I just have no idea what...

How to do activity transtion?

I have implemented one App which has many activities.. . I want to implement one activity as left and right and vice versa in fling transition manner between whole activity. For example
SO when you hit next there should be transition between next activity and when you hit previous there should be transition between previous . How should i Implement this?. ... Its fling but not with touch, but using those buttons...
Check out ViewFlipper (video demo here), ViewPager, or ViewPagerIndicator.
Define translation animations in xml then use overridePendingTransition BEFORE setContentView in each Activity. E.g. overridePendingTransition(R.anim.slidein, R.anim.slideout); You probably need to put this in onResume if you want it to work both ways (i.e. when you're going from and back to that Activity.).

Categories

Resources