4

Background

In the past, Google presented the Fragments classes (which I've also asked when should we use it, here).

Now, Android 4.4 has a new framework class called "Scene".

According to what I've read (and watched on lectures, for example here), it's supposed to help you with animations and transitions between states.

The question

Actually I have a few questions about this:

  1. In which cases would I know when to use it? Is it just for animations and considered a "bonus" to your app? Or does it also present some logic like Fragments and Activities?

  2. What is the difference between using it and just animating each view you'd like to animate?

  3. Are there any official samples for this?

  4. Is there any compatibility library, to use it on pre-4.4 versions?

Community
  • 1
  • 1
android developer
  • 114,585
  • 152
  • 739
  • 1,270

2 Answers2

5

Is it just for animations

Yes.

Or does it also present some logic like Fragments and Activities?

That depends upon your definition of "logic".

What is the difference between using it and just animating each view you'd like to animate?

Simplicity.

Are there any official samples for this?

There is one on your hard drive already, assuming you have downloaded the SDK samples.

See also Mark Allison's blog post series.

Is there any compatibility library, to use it on pre-4.4 versions?

No, but there is a community backport.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Yes, I've now tried the sample on the emulator, and I think it does make it a bit easier. By "logic" I mean something more than just UI/UX. As you know, Fragments can contain not just handling UI, but also more POJO code. In fact they don't even have to show anything. – android developer Apr 30 '14 at 19:40
  • @androiddeveloper: No, AFAIK the vision for `Scene` and the transition framework is just for the animation effects, nothing more. – CommonsWare Apr 30 '14 at 20:04
  • So it's not a big change like Fragments. I see. Wonder if there are any apps out there that use it, to see more examples of when it's useful. – android developer Apr 30 '14 at 20:14
  • @androiddeveloper: You can't really tell from the outside what is using the transitions framework and what is doing the animations in some other way. So, short of a blog post somewhere saying "yay, transitions framework!", it'll be difficult to identify implementations. – CommonsWare Apr 30 '14 at 20:18
  • Yes, it's hard to tell anything by looking, but maybe there are certain apps that the developers said they used it. quite rare, but google does this sometimes. – android developer Apr 30 '14 at 20:22
1

1. Scenes is a better way to change a rootView in activitys/fragments.

Example:

    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scene_transitions);

    rootContainer = 
                  (ViewGroup) findViewById(R.id.rootContainer);

    scene1 = Scene.getSceneForLayout(rootContainer, 
                     R.layout.scene1_layout, this);

    scene2 = Scene.getSceneForLayout(rootContainer, 
                      R.layout.scene2_layout, this);

    scene1.enter();
}

2. Less source code, more performance and simple.

3. Not exist official samples for this.

Unofficial Samples: http://www.techotopia.com/index.php/Implementing_Android_Scene_Transitions_%E2%80%93_A_Tutorial

4. Lib support v4 I think.

Link: https://developer.android.com/reference/android/transition/Scene.html

extmkv
  • 1,991
  • 1
  • 18
  • 36
  • #3. According to the link (which I've also seen), it seems like an animation between multiple views, and not just between 2 views. I still wish to understand it better. #4. I don't see it. What is the name of the class of the support library? – android developer Apr 30 '14 at 18:40