Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top