Esempio n. 1
0
        protected override void OnCreate (Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);
            ActionBar.Hide(); 

            // Get our button from the layout resource,
            // and attach an event to it
            var layout = FindViewById<RelativeLayout> (Resource.Id.mainLayout);
            layout.SetBackgroundColor(Color.Black);
            var txt = FindViewById<TextView> (Resource.Id.introText);
            var logo = FindViewById<ImageView> (Resource.Id.logoImage);
            layout.SetCommand ("Click", Vm.LaunchCommand);

            TranslateAnimation transAnim = new TranslateAnimation(0, 0, -500, Resources.DisplayMetrics.HeightPixels / 5);
            transAnim.SetAnimationListener(this);
            transAnim.Interpolator = new BounceInterpolator();
            transAnim.StartOffset = 500;
            transAnim.Duration = 1500;
            transAnim.FillAfter = true;
            logo.StartAnimation(transAnim);

            AlphaAnimation fadeTextIn = new AlphaAnimation(0.0f, 1.0f); 
            txt.StartAnimation(fadeTextIn);
            fadeTextIn.StartOffset = transAnim.StartOffset + transAnim.Duration;
            fadeTextIn.Duration = 1000;
            fadeTextIn.FillAfter = true;
        }
Esempio n. 2
0
 private Animation CreateTranslationInAnimation()
 {
     const Dimension type = Dimension.RelativeToSelf; //TranslateAnimation.RELATIVE_TO_SELF;
     var an = new TranslateAnimation(type, 0, type, 0, type, 1, type, 0)
     {
         Duration = TranslateDuration
     };
     return an;
 }
		public override void OnActivityCreated (Bundle savedInstanceState)
		{
			base.OnActivityCreated (savedInstanceState);

			InitWidth();
			InitTextView();
			InitViewPager();
			TranslateAnimation animation = new TranslateAnimation(position_one, offset, 0, 0){FillAfter = true,Duration = 300};
			ivBottomLine.StartAnimation(animation);
		}
 public static Animation BuildDefaultSlideOutUpAnimation(View croutonView)
 {
     if (_lastOutAnimationHeight != croutonView.MeasuredHeight || (null == _slideOutUpAnimation))
     {
         _slideOutUpAnimation = new TranslateAnimation(0, 0, 0, -croutonView.MeasuredHeight);
         _slideOutUpAnimation.Duration = Duration;
         _lastOutAnimationHeight = croutonView.MeasuredHeight;
     }
     return _slideOutUpAnimation;
 }
		private void InitView()
		{
			//设置标题栏
			var btn_header_back = FindViewById<Button> (Resource.Id.btn_header_back);
			btn_header_back.Click += (sender, e) => 
			{
				this.Finish();
				OverridePendingTransition(Android.Resource.Animation.SlideInLeft,Android.Resource.Animation.SlideOutRight);
			};
			var tv_header_title = FindViewById<TextView> (Resource.Id.tv_header_title);
			tv_header_title.Text = "投诉建议";
			InitWidth();
			InitTabBtnView();
			InitViewPager();
			TranslateAnimation animation = new TranslateAnimation(position_one, offset, 0, 0){FillAfter = true,Duration = 300};
			ivBottomLine.StartAnimation(animation);
		}
        void HandleTouch(object sender, TouchEventArgs e)
        {
            if (e.Event.Action == Android.Views.MotionEventActions.Down)
            {
                Control.SetX(0);
                Control.ClearAnimation();
            }
            var swiped = _detector.OnTouchEvent(e.Event);

            if (swiped)
            {
                try
                {
                    var endPoint = e.Event.HistorySize;
                    var end      = e.Event.GetHistoricalX(endPoint - 1);
                    var start    = e.Event.GetHistoricalX(0);
                    var dif      = end - start;
                    if (dif > 0)
                    {
                        Control.TranslationX = Control.TranslationX + dif;
                    }
                }
                catch (Exception)
                {
                    //sometimes historicalX gets out of bounds coz xamarin is so well written
                }
            }
            if (e.Event.Action == Android.Views.MotionEventActions.Up || e.Event.Action == Android.Views.MotionEventActions.Cancel)
            {
                var delta = Control.GetX();
                if (delta > 300)//arbitrarynumber no point in getting it every time, should be probed once based on time on app startup,
                {
                    animation = GetDeletingAnimation();
                    animation.AnimationEnd += DeleteControl;
                }
                else
                {
                    animation = GetReturnAnimation(delta);
                }
                Control.StartAnimation(animation);
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            //RequestWindowFeature(WindowFeatures.ActionBar);
            SetContentView(Resource.Layout.ItemDetails);

            _txtName = FindViewById<TextView>(Resource.Id.txtName);
            progresBar = FindViewById<ProgressBar>(Resource.Id.progressBar1);

            moveDownAnimation = new TranslateAnimation(0, 0, -200, 0);
            moveDownAnimation.Duration = 1000;
            moveDownAnimation.FillAfter = true;
            moveDownAnimation.Interpolator = new BounceInterpolator();
            _txtName.Visibility =  ViewStates.Gone;
            //_txtDescription = FindViewById<TextView>(Resource.Id.txtDescription);
            //_txtPrice = FindViewById<TextView>(Resource.Id.txtAsking);
            //_txtRetail = FindViewById<TextView>(Resource.Id.txtRetail);
            _imgItem = FindViewById<ImageView>(Resource.Id.imgItem);
            _imgItem.Visibility = ViewStates.Gone;
            _imgItem.Dispose();
        }
 public override bool OnFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
 {
     if (Math.Abs(velocityX) < 500) return false;
     _lastView = _parentActivity.LastView;
     var animationSet = new AnimationSet(true)
     {
         Interpolator = new AccelerateDecelerateInterpolator(),
         Duration = 300,
         FillAfter = true
     };
     var animationRotate = new RotateAnimation(0, Math.Sign(velocityX)*15);
     var animationTranslate = new TranslateAnimation(0, Math.Sign(velocityX)*400,
         0, 10);
     var animationAlpha = new AlphaAnimation(1, 0);
     animationSet.AddAnimation(animationRotate);
     animationSet.AddAnimation(animationTranslate);
     animationSet.AddAnimation(animationAlpha);
     animationSet.AnimationEnd += AnimationSet_AnimationEnd;
     _lastView.StartAnimation(animationSet);
     return true;
 }
Esempio n. 9
0
        private Animation SwipeDragAnimation(float activeX)
        {
            float delX = activeX - _lastX;

            Animation translate = new TranslateAnimation (Offset, Offset + delX, 0, 0);
            translate.Duration = 0;
            translate.FillAfter = true;

            return translate;
        }
Esempio n. 10
0
        public virtual void Show()
        {
            var moveRightToLeft = new TranslateAnimation(-(_textWidth*2), 0, 0, 0)
            {
                Duration = ShowSpeed,
                FillAfter = true
            };

            _dotThree.StartAnimation(moveRightToLeft);

            moveRightToLeft = new TranslateAnimation(-_textWidth, 0, 0, 0) {Duration = ShowSpeed, FillAfter = true};

            _dotTwo.StartAnimation(moveRightToLeft);
            _isHide = false;
        }
Esempio n. 11
0
 private Animation CreateTranslationOutAnimation()
 {
     TranslateAnimation an = new TranslateAnimation(Dimension.RelativeToSelf, 0,
         Dimension.RelativeToSelf, 0, Dimension.RelativeToSelf, 0, Dimension.RelativeToSelf, 1);
     an.Duration = TRANSLATE_DURATION;
     an.FillAfter = true;
     return an;
 }
Esempio n. 12
0
        private void AnimateTopLayer(float percent, bool force = false)
        {
            if (!canAnimate)
                return;

            if (height <= 0) {
                height = (float)topLayer.MeasuredHeight;
                if (height <= 0)
                    return;
            }

            canAnimate = false;

            var start = animation == null ? -height : lastY;
            var time = 300;
            IInterpolator interpolator;

            if (percent < 0)
                percent = 0;
            else if (percent > 100)
                percent = 100;

            lastY = -height * (percent / 100F);

            if ((int)lastY == (int)start && !force) {
                canAnimate = true;
                return;
            }

            //is new so do bound, else linear
            if (fullAnimation || !Utils.IsSameDay) {
                interpolator = new BounceInterpolator ();
                time = 3000;
                fullAnimation = false;
            } else {
                interpolator = new LinearInterpolator ();
            }
            animation = new TranslateAnimation (Dimension.Absolute, 0,
                Dimension.Absolute, 0,
                Dimension.Absolute, start,
                Dimension.Absolute, lastY);
            animation.Duration = time;

            animation.Interpolator = interpolator;
            animation.AnimationEnd += (object sender, Animation.AnimationEndEventArgs e) => {
                canAnimate = true;
            };

            animation.FillAfter = true;
            topLayer.StartAnimation(animation);
            if (topLayer.Visibility != Android.Views.ViewStates.Visible)
                topLayer.Visibility = Android.Views.ViewStates.Visible;
        }
Esempio n. 13
0
        /**
	 * Slide animations to hide a view by sliding it to the top
	 * 
	 * @param duration the animation duration in milliseconds
	 * @param interpolator the interpolator to use (pass {@code null} to use the {@link AccelerateInterpolator} interpolator) 	
	 * @return a slide transition animation
	 */

        public static Animation OutToTopAnimation(long duration, IInterpolator interpolator)
        {
            Animation outtotop = new TranslateAnimation(
                Dimension.RelativeToParent, 0.0f, Dimension.RelativeToParent, 0.0f,
                Dimension.RelativeToParent, 0.0f, Dimension.RelativeToParent, -1.0f
                );
            outtotop.Duration = duration;
            outtotop.Interpolator = interpolator ?? new AccelerateInterpolator();
            return outtotop;
        }
Esempio n. 14
0
 private Animation CreateTranslationInAnimation()
 {
     TranslateAnimation an = new TranslateAnimation(Dimension.RelativeToSelf, 0,
         Dimension.RelativeToSelf, 0, Dimension.RelativeToSelf, 1, Dimension.RelativeToSelf, 0);
     an.Duration = TRANSLATE_DURATION;
     return an;
 }
		/// <summary>
		/// 新的页面被选中调用
		/// </summary>
		/// <param name="position">Position.</param>
		public void OnPageSelected(int position)
		{
			Animation animation = null;
			switch (position)
			{
			case 0:
				if (currentIndex == 1) {
					animation = new TranslateAnimation (position_one, offset, 0, 0);
					tvTabmyAlarm.SetTextColor (Resources.GetColor (Resource.Color.blue));
				} 
					
				tvTabotherAlarm.SetTextColor (Resources.GetColor (Resource.Color.darkgray));

					break;
			case 1:
				if (currentIndex == 0) {
					animation = new TranslateAnimation (offset, position_one, 0, 0);
					tvTabotherAlarm.SetTextColor (Resources.GetColor (Resource.Color.blue));
				} 
				tvTabmyAlarm.SetTextColor (Resources.GetColor(Resource.Color.darkgray));
					break;
			}
				
			animation.FillAfter = true;
			animation.Duration = 300;
			ivBottomLine.StartAnimation (animation);
			currentIndex = position;
		}
Esempio n. 16
0
        /**
	 * Slide animations to enter a view from top.
	 * 
	 * @param duration the animation duration in milliseconds
	 * @param interpolator the interpolator to use (pass {@code null} to use the {@link AccelerateInterpolator} interpolator) 	
	 * @return a slide transition animation
	 */

        public static Animation InFromTopAnimation(long duration, IInterpolator interpolator)
        {
            Animation infromtop = new TranslateAnimation(
                Dimension.RelativeToParent, 0.0f, Dimension.RelativeToParent, 0.0f,
                Dimension.RelativeToParent, -1.0f, Dimension.RelativeToParent, 0.0f
                );
            infromtop.Duration = duration;
            infromtop.Interpolator = interpolator ?? new AccelerateInterpolator();
            return infromtop;
        }
Esempio n. 17
0
        private Animation SwipeEndAnimation()
        {
            TranslateAnimation translate = null;

            if (ShouldDeleteSwipeView())
            {
                if (_lastX > _firstX)
                {
                    translate = new TranslateAnimation (Offset, _swipeView.Width, 0, 0);
                }
                else
                {
                    translate = new TranslateAnimation (Offset, -_swipeView.Width, 0, 0);
                }
            }
            else
            {
                translate = new TranslateAnimation (Offset, 0, 0, 0);
            }

            translate.Duration = 330;
            translate.FillAfter = true;

            return translate;
        }
Esempio n. 18
0
        private void animateAlphaTranslate(View view, float alphaFrom, float alphaTo, float xFrom, float xTo,
            bool requestFocus)
        {
            AnimationSet animationSet = new AnimationSet(true);

            AlphaAnimation fade = new AlphaAnimation(alphaFrom, alphaTo);
            fade.Duration = 350;

            TranslateAnimation slide = new TranslateAnimation(Dimension.RelativeToSelf, xFrom,
                                                              Dimension.RelativeToSelf, xTo,
                                                              Dimension.RelativeToSelf, 0,
                                                              Dimension.RelativeToSelf, 0);

            slide.Duration = 350;

            animationSet.AddAnimation(fade);
            animationSet.AddAnimation(slide);
            view.StartAnimation(animationSet);

            if (requestFocus)
            {
                animationSet.AnimationEnd += (obj, args) => view.RequestFocus();
            }
        }
        private void MaximizeView(View view)
        {
            var animationSet = new AnimationSet(true)
            {
                Interpolator = new AccelerateDecelerateInterpolator(),
                Duration = 500,
                FillAfter = true
            };
            var scaleAnimation = new ScaleAnimation(1f, 1.25f, 1f, 1.25f, Dimension.RelativeToSelf, 0f,
                Dimension.RelativeToSelf, 0f);
            _selectedViewTop = view.Top;
            _selectedViewLeft = view.Left;
            var translateAnimation = new TranslateAnimation(Dimension.RelativeToSelf, 0, Dimension.Absolute, -view.Left,
                Dimension.RelativeToSelf, 0, Dimension.Absolute, -view.Top + _addButton.Height);
            animationSet.AddAnimation(scaleAnimation);
            animationSet.AddAnimation(translateAnimation);

            view.StartAnimation(animationSet);
        }
    private void Toggle (bool visible, bool animate, bool force)
    {
      if (Visible != visible || force) {
        Visible = visible;
        lastToggleAnimate = animate;
        int height = Height;
        if (height == 0 && !force) {
          var vto = ViewTreeObserver;
          if (vto.IsAlive) {
            vto.AddOnPreDrawListener (this);
            return;
          }
        }
        var translationY = visible ? 0 : height + MarginBottom;
        if (animate) {

          if ((int)Build.VERSION.SdkInt >= 12) {
            #if __ANDROID_12__
            Animate ().SetInterpolator (interpolator)
            .SetDuration (TranslateDurationMillis)
            .TranslationY (translationY);
            #endif
          } else {
            var oldY = !visible ? 0 : height + MarginBottom;
            var animation = new TranslateAnimation (0, 0, oldY, translationY);
            animation.Duration = TranslateDurationMillis;
            if (visible)
            {
              animation.AnimationStart += (sender, e) => {
                this.Visibility = ViewStates.Visible;
              };
            }   
            else {
              animation.AnimationEnd += (sender, e) => {
                this.Visibility = ViewStates.Gone; 
              };
            }
            this.StartAnimation (animation);

          }
        } else {

          if ((int)Build.VERSION.SdkInt >= 11) {
            #if __ANDROID_11__
            this.TranslationY = translationY;
            #endif
          }
          else{
            var oldY = !visible ? 0 : height + MarginBottom;
            var animation = new TranslateAnimation (0, 0, oldY, translationY);
            animation.Duration = 0;

            if (visible)
            {
              animation.AnimationStart += (sender, e) => {
                this.Visibility = ViewStates.Visible;
              };
            }   
            else {
              animation.AnimationEnd += (sender, e) => {
                this.Visibility = ViewStates.Gone; 
              };
            }
            this.StartAnimation (animation);
          }

        }

        if (!HasHoneycombApi) {
          Clickable = visible;
        }
      }
    }
Esempio n. 21
0
        TranslateAnimation Move_Card(ImageView ivStart, ImageView ivEnd, long duration)
        {
            int[] startPosition = Position_Of (ivStart);
            int[] endPosition = Position_Of (ivEnd);
            TranslateAnimation anim = new TranslateAnimation(
                Dimension.Absolute, startPosition [0], Dimension.Absolute, endPosition [0] - group.PaddingLeft,//from to X
                Dimension.Absolute, startPosition [1] - group.PaddingTop, Dimension.Absolute, endPosition [1] - (1+lp.Height));//from to Y
            anim.Duration = duration;
            anim.FillAfter = true;
            MyAnimationListener myAnimationListener = new MyAnimationListener (this);
            MyAnimationListener.AnimationEnded += AnimationEndedHandler;
            anim.SetAnimationListener (myAnimationListener);

            return anim;
        }
Esempio n. 22
0
		public void showLeyenda()
		{

			int xi;
			int xf;
			if (_leyendaShowed) {

				xf = 0;
				xi = Configuration.getWidth (500);
				//leyendaLayout.SetX (0);
				_leyendaShowed = false;

			} else {
				xf = -Configuration.getWidth (500);
				xi = 0;
				_leyendaShowed = true;
			}

			TranslateAnimation transAnimation = new TranslateAnimation (xi,xf, 0, 0);
			transAnimation.Duration = 500;
			transAnimation.FillAfter = true;
			leyendaLayout.StartAnimation (transAnimation);
		}
Esempio n. 23
0
        /**
	 * Slide animations to enter a view from right.
	 * 
	 * @param duration the animation duration in milliseconds
	 * @param interpolator the interpolator to use (pass {@code null} to use the {@link AccelerateInterpolator} interpolator) 	
	 * @return a slide transition animation
	 */

        public static Animation InFromRightAnimation(long duration, IInterpolator interpolator)
        {

            Animation inFromRight = new TranslateAnimation(
                Dimension.RelativeToParent, +1.0f, Dimension.RelativeToParent, 0.0f,
                Dimension.RelativeToParent, 0.0f, Dimension.RelativeToParent, 0.0f
                );
            inFromRight.Duration = duration;
            inFromRight.Interpolator = interpolator ?? new AccelerateInterpolator();
            return inFromRight;
        }
Esempio n. 24
0
 private Animation CreateTranslationOutAnimation()
 {
     const Dimension type = Dimension.RelativeToSelf;
     TranslateAnimation an = new TranslateAnimation(type, 0, type, 0, type, 0, type, 1)
     {
         Duration = TranslateDuration,
         FillAfter = true
     };
     return an;
 }
Esempio n. 25
0
		// 初始化上下回弹的动画效果
		private void upDownMoveAnimation() {
			TranslateAnimation animation = new TranslateAnimation(0.0f, 0.0f,
				childView.Top, topRect.Top);
			animation.Duration=300;
			animation.Interpolator = new AccelerateInterpolator ();
			childView.Animation =animation;
		}