Пример #1
0
        public void OnAnimationEnd(Animation animation)
        {
            // This method is called at the end of the animation for the fragment transaction,
            // which is perfect time to start our Transition.
            Log.Info(TAG, "Fragment animation ended. Starting a Transition.");
            Scene scene = Scene.GetSceneForLayout((ViewGroup)this.View,
                                                  Resource.Layout.fragment_detail_content, this.Activity);

            TransitionManager.Go(scene);
            // Note that we need to bind views with data after we call TransitionManager.go().
            Bind(scene.SceneRoot);
        }
Пример #2
0
 void RunTransition()
 {
     if (currentScene == 1)
     {
         TransitionManager.Go(scene2);
         currentScene++;
     }
     else
     {
         TransitionManager.Go(scene1);
         currentScene--;
     }
 }
Пример #3
0
        public void OnClick(View v)
        {
            switch (v.Id)
            {
            case Resource.Id.show_next_scene: {
                current_scene = (current_scene + 1) % scenes.Length;
                Log.Info(TAG, "Transitioning to scene #" + current_scene);

                //Pass the custom Transition as second argument for TransitionManager.go
                TransitionManager.Go(scenes [current_scene], transition);
                break;
            }
            }
        }
Пример #4
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            FrameLayout container = (FrameLayout)view.FindViewById(Resource.Id.container);

            view.FindViewById(Resource.Id.show_next_scene).SetOnClickListener(this);
            if (null != savedInstanceState)
            {
                current_scene = savedInstanceState.GetInt(STATE_CURRENT_SCENE);
            }

            //Set up the scenes
            scenes = new Scene[] {
                Scene.GetSceneForLayout(container, Resource.Layout.scene1, Activity),
                Scene.GetSceneForLayout(container, Resource.Layout.scene2, Activity),
                Scene.GetSceneForLayout(container, Resource.Layout.scene3, Activity),
            };

            //Show the initial Scene
            transition = new ChangeColor();
            TransitionManager.Go(scenes [current_scene % scenes.Length]);
        }
Пример #5
0
        private void AnimateButtonClick(object sender, EventArgs e)
        {
            _currentSceneNumber = _currentSceneNumber == 1 ? 2 : 1;

            var scene = _currentSceneNumber switch
            {
                1 => _scene1,
                2 => _scene2,
                _ => throw new NotImplementedException()
            };

            var set = new TransitionSet();

            set.AddTransition(new Explode());
            set.AddTransition(new ChangeBounds());
            set.AddTransition(new CustomTransition());
            set.SetOrdering(TransitionOrdering.Together);
            set.SetDuration(500);
            set.SetInterpolator(new DecelerateInterpolator());

            TransitionManager.Go(scene, set);
        }
Пример #6
0
        public override Animator OnCreateAnimator(FragmentTransit transit, bool enter, int nextAnim)
        {
            Animator animator = AnimatorInflater.LoadAnimator(Activity,
                                                              enter ? Android.Resource.Animator.FadeIn : Android.Resource.Animator.FadeOut);

            // We bind a listener for the fragment transaction. We only bind it when
            // this fragment is entering.
            if (animator != null && enter)
            {
                animator.AnimationEnd += (object sender, EventArgs e) => {
                    // This method is called at the end of the animation for the fragment transaction,
                    // which is perfect time to start our Transition.
                    Log.Info(TAG, "Fragment animation ended. Starting a Transition.");
                    Scene scene = Scene.GetSceneForLayout((ViewGroup)View, Resource.Layout.fragment_detail_content, Activity);
                    TransitionManager.Go(scene);
                    // Note that we need to bind views with data after we call TransitionManager.go().
                    Bind(scene.SceneRoot);
                }
            }
            ;

            return(animator);
        }
    }
Пример #7
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			SetContentView (Resource.Layout.Transition);

			#region property animation

			button = FindViewById<Button> (Resource.Id.button);
			text = FindViewById<TextView> (Resource.Id.textView);
			linear = FindViewById<LinearLayout> (Resource.Id.linear);

			if(bundle != null) {
				if(bundle.GetBoolean("visible")) {
					text.Visibility = ViewStates.Visible;
				}
				visible = bundle.GetBoolean("visible");
			}

			// This button demonstrates a simple property animation
			button.Click += (o, e) => {

				// OS version check since transition manager is only available in KitKat+
				var version = BuildVersionCodes.Kitkat;
				if(Build.VERSION.SdkInt >= version) {
					TransitionManager.BeginDelayedTransition (linear);
				}

				// show and hide the text, so we can see the smooth transition
				if(text.Visibility != ViewStates.Visible)
				{
					text.Visibility = ViewStates.Visible;
					visible = true;
				}
				else
				{
					text.Visibility = ViewStates.Invisible;
					visible = false;
				}
			};

			#endregion

			#region scenes

			// the container holds the dynamic content what will be changing when we 
			// change Scenes
			container = FindViewById<RelativeLayout> (Resource.Id.container);
			sceneButton = FindViewById<Button> (Resource.Id.sceneButton);

			// Define the transition and inflate it from the xml
			transition = TransitionInflater.From(this).InflateTransition(Resource.Transition.transition);

			// Define scenes that we're going to use

			// NOTE: There is a known Java bug in GetSceneForLayout (https://code.google.com/p/android/issues/detail?id=62450)
			// It may not work as intended the second time an activity is launched (relaunch or configuration change)
			scene1 = Scene.GetSceneForLayout(container, Resource.Layout.Scene1, this);
			scene2 = Scene.GetSceneForLayout(container, Resource.Layout.Scene2, this);

			scene1.Enter();

			sceneButton.Click += (o, e) => {
				// reserve variables. This keeps the animation going both ways.
				Scene temp = scene2;
				scene2 = scene1;
				scene1 = temp;

				TransitionManager.Go (scene1, transition);
			};

			#endregion

		}