32

Every time i search i came across this " android 5(L) activity transition only available on API >= 21 .

that's fine but i can see some app like QuickPic and google inbox that use similar transition and also working on lower api, so how this app can do such a thing?

what i have done?

1) a lot of search:)

2) playing with ActivityOptionsCompat that only apply to api >= 21, like this:

ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, transitionView, DATA.EXTRA_PASSED_JSON);
Intent intent = new Intent(activity, PhotoViewerActivity.class);
intent.putExtra(DATA.EXTRA_PASSED_JSON, json);
ActivityCompat.startActivity(activity, intent, options.toBundle());

EDIT(question marked as duplicate): it's different from other question in this case, because i said there is other app that do this transition in lower api and i want to know how they do that.

mehdok
  • 1,499
  • 4
  • 29
  • 54
  • @alex-lockwood in the future when you decide to singlehandly close a ticket for being a duplicate, please link to the duplicate post. – edthethird Oct 05 '17 at 16:50

2 Answers2

38

We added a lot of stuff in Lollipop to make Activity Transitions work well. It is possible to do Activity Transitions manually (in earlier versions), but you will encounter problems in some cases and the return transition is likely going to work only in the simplest case. Chet Haase has a devbyte on this here.

Animations between fragments were possible earlier, though the API isn't as easy to use as in Lollipop's Fragment Transitions.

We thought a lot about back porting transitions to earlier versions in the support library. It may still happen. If so, we should also be able to do something for Fragment Transitions.

Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
George Mount
  • 20,708
  • 2
  • 73
  • 61
  • 15
    in the recent update to Gmail app, we can see that the makeSceneTransitionAnimation is possible in pre-lollipop devices as well, can you please let me know how can we achieve this ? – user2056563 Apr 27 '15 at 10:45
  • 9
    good news foks it happens they have added it in v4 support lib take a look at https://developer.android.com/reference/android/support/transition/package-summary.html – Ajinkya Aug 18 '16 at 09:44
22

Like you say yourself, the support library does not support (all) transitions on Android versions below 5.0. There are however some alternatives:

Unofficial Compatibility libraries
https://github.com/andkulikov/transitions-everywhere
https://github.com/takahirom/PreLollipopTransition
https://github.com/lgvalle/Material-Animations

Android KitKat
http://www.doubleencore.com/2013/11/new-transitions-framework/ and a sample found in your SDK samples folder.

Mdlc
  • 7,128
  • 12
  • 55
  • 98
  • tnx, i think i can make this work. – mehdok Dec 07 '14 at 16:19
  • with the library you linked i can use transition between 2 view in lower api but i can't figure out how to apply transition between 2 `activity`, can you hint me? – mehdok Dec 07 '14 at 17:15
  • 3
    You can load the view of the second activity, then, perform an intent without animation. Ofcourse, this is more difficult when you next activity has different content. – Mdlc Dec 08 '14 at 14:31
  • I tried https://github.com/takahirom/PreLollipopTransition between two activities and its working. Do you have any idea if we can do transition of multiple elements using it? – Srujan Barai Aug 30 '15 at 09:05
  • I doesn't look like PreLollipopTransition supports multiple elements. You can try using a view container (e.g. a relativelayout) if you want to transfer multiple elements at once. You can try using the other library or filing this as a future suggestion to the library. – Mdlc Aug 30 '15 at 09:36