Java Code Examples for android.transition.Scene#getSceneForLayout()

The following examples show how to use android.transition.Scene#getSceneForLayout() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomTransitionFragment.java    From animation-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    Context context = getActivity();
    FrameLayout container = (FrameLayout) view.findViewById(R.id.container);
    view.findViewById(R.id.show_next_scene).setOnClickListener(this);
    if (null != savedInstanceState) {
        mCurrentScene = savedInstanceState.getInt(STATE_CURRENT_SCENE);
    }
    // We set up the Scenes here.
    mScenes = new Scene[] {
            Scene.getSceneForLayout(container, R.layout.scene1, context),
            Scene.getSceneForLayout(container, R.layout.scene2, context),
            Scene.getSceneForLayout(container, R.layout.scene3, context),
    };
    // This is the custom Transition.
    mTransition = new ChangeColor();
    // Show the initial Scene.
    TransitionManager.go(mScenes[mCurrentScene % mScenes.length]);
}
 
Example 2
Source File: MainActivity.java    From auid2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mSceneRoot = (ViewGroup) findViewById(R.id.scene_root);

    mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene1, this);
    mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene2, this);

    mTransition = new ChangeBounds();
    mTransition.setDuration(DateUtils.SECOND_IN_MILLIS);
    mTransition.setInterpolator(new AccelerateDecelerateInterpolator());
    TransitionManager.go(mScene1);
    mCurrentScene = mScene1;

    findViewById(R.id.button).setOnClickListener(this);
}
 
Example 3
Source File: MainActivity.java    From Android-9-Development-Cookbook with MIT License 5 votes vote down vote up
public void goAnimate(View view) {
        //Resource file solution
        ViewGroup root = findViewById(R.id.layout);
        Scene scene = Scene.getSceneForLayout(root, R.layout.activity_main_end, this);
        Transition transition = TransitionInflater.from(this)
                .inflateTransition(R.transition.transition_move);
        TransitionManager.go(scene, transition);

        //Code only solution
//        ViewGroup root = findViewById(R.id.layout);
//        Scene scene = new Scene(root);
//
//        Transition transition = new ChangeBounds();
//        TransitionManager.beginDelayedTransition(root,transition);
//
//        TextView textViewTop = findViewById(R.id.textViewTop);
//        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)textViewTop.getLayoutParams();
//        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,1);
//        params.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
//        textViewTop.setLayoutParams(params);
//
//        TextView textViewBottom = findViewById(R.id.textViewBottom);
//        params = (RelativeLayout.LayoutParams) textViewBottom.getLayoutParams();
//        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,0);
//        params.addRule(RelativeLayout.ALIGN_PARENT_TOP, 1);
//        textViewBottom.setLayoutParams(params);
//
//        TransitionManager.go(scene);
    }
 
Example 4
Source File: MainActivity.java    From cogitolearning-examples with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main_activity);

  container = (ViewGroup) findViewById(R.id.main_container);
  webSiteForm = Scene.getSceneForLayout(container, R.layout.scene_link, this);
  pictureForm = Scene.getSceneForLayout(container, R.layout.scene_picture, this);
  contactForm = Scene.getSceneForLayout(container, R.layout.scene_contact, this);
  eventForm   = Scene.getSceneForLayout(container, R.layout.scene_event, this);
}
 
Example 5
Source File: AlbumDetailActivity.java    From android-animations-transitions with MIT License 4 votes vote down vote up
private void setupTransitions() {
//        Slide slide = new Slide(Gravity.BOTTOM);
//        slide.excludeTarget(android.R.id.statusBarBackground, true);
//        getWindow().setEnterTransition(slide);
//        getWindow().setSharedElementsUseOverlay(false);

        mTransitionManager = new TransitionManager();
        ViewGroup transitionRoot = detailContainer;

        // Expanded scene
        mExpandedScene = Scene.getSceneForLayout(transitionRoot,
                R.layout.activity_album_detail_expanded, this);

        mExpandedScene.setEnterAction(new Runnable() {
            @Override
            public void run() {
                ButterKnife.bind(AlbumDetailActivity.this);
                populate();
                mCurrentScene = mExpandedScene;
            }
        });

        TransitionSet expandTransitionSet = new TransitionSet();
        expandTransitionSet.setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
        ChangeBounds changeBounds = new ChangeBounds();
        changeBounds.setDuration(200);
        expandTransitionSet.addTransition(changeBounds);

        Fade fadeLyrics = new Fade();
        fadeLyrics.addTarget(R.id.lyrics);
        fadeLyrics.setDuration(150);
        expandTransitionSet.addTransition(fadeLyrics);

        // Collapsed scene
        mCollapsedScene = Scene.getSceneForLayout(transitionRoot,
                R.layout.activity_album_detail, this);

        mCollapsedScene.setEnterAction(new Runnable() {
            @Override
            public void run() {
                ButterKnife.bind(AlbumDetailActivity.this);
                populate();
                mCurrentScene = mCollapsedScene;
            }
        });

        TransitionSet collapseTransitionSet = new TransitionSet();
        collapseTransitionSet.setOrdering(TransitionSet.ORDERING_SEQUENTIAL);

        Fade fadeOutLyrics = new Fade();
        fadeOutLyrics.addTarget(R.id.lyrics);
        fadeOutLyrics.setDuration(150);
        collapseTransitionSet.addTransition(fadeOutLyrics);

        ChangeBounds resetBounds = new ChangeBounds();
        resetBounds.setDuration(200);
        collapseTransitionSet.addTransition(resetBounds);

        mTransitionManager.setTransition(mExpandedScene, mCollapsedScene, collapseTransitionSet);
        mTransitionManager.setTransition(mCollapsedScene, mExpandedScene, expandTransitionSet);
        mCollapsedScene.enter();

//        postponeEnterTransition();
    }