/// <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); btnTabmyHealth.SetTextColor(Resources.GetColor(Resource.Color.blue)); } btnTabotherHealth.SetTextColor(Resources.GetColor(Resource.Color.black)); break; case 1: if (currentIndex == 0) { animation = new TranslateAnimation(offset, position_one, 0, 0); btnTabotherHealth.SetTextColor(Resources.GetColor(Resource.Color.blue)); } btnTabmyHealth.SetTextColor(Resources.GetColor(Resource.Color.black)); break; } animation.FillAfter = true; animation.Duration = 300; ivBottomLine.StartAnimation(animation); currentIndex = position; }
public static LayoutAnimationController getListAnimTranslate() { try { AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.Duration = 500;//(500); set.AddAnimation(animation); animation = new TranslateAnimation(Dimension.RelativeToSelf, 0.0f, Dimension.RelativeToSelf, 0.0f, Dimension.RelativeToSelf, -1.0f, Dimension.RelativeToSelf, 0.0f); animation.Duration = 800; //(800); set.AddAnimation(animation); LayoutAnimationController controller = new LayoutAnimationController( set, 0.5f); controller.Order = DelayOrder.Random; return(controller); } catch (Exception) { return(null); } }
public void StartSecondaryCircleAnimation() { int bottomMovementAddition = (260 * parentWidth) / 700; TranslateAnimation translateAnimation = new TranslateAnimation(GetX(), GetX(), GetY(), GetY() + bottomMovementAddition) { StartOffset = 200, Duration = 1000 }; AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0) { StartOffset = 1300, Duration = 200 }; AnimationSet animationSet = new AnimationSet(true) { FillAfter = true }; animationSet.AddAnimation(translateAnimation); animationSet.AddAnimation(alphaAnimation); animationSet.AnimationEnd += (s, e) => { SetState(AnimationState.SecondaryCircleFinished); }; StartAnimation(animationSet); }
/// <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); tab_btn_writeAdvice.SetTextColor(Resources.GetColor(Resource.Color.blue)); } tab_btn_recordAdvice.SetTextColor(Resources.GetColor(Resource.Color.darkgray)); break; case 1: if (currentIndex == 0) { animation = new TranslateAnimation(offset, position_one, 0, 0); tab_btn_recordAdvice.SetTextColor(Resources.GetColor(Resource.Color.blue)); } tab_btn_writeAdvice.SetTextColor(Resources.GetColor(Resource.Color.darkgray)); break; } animation.FillAfter = true; animation.Duration = 300; ivBottomLine.StartAnimation(animation); currentIndex = position; }
protected override void OnSizeChanged(int width, int height, int oldw, int oldh) { base.OnSizeChanged(width, height, oldw, oldh); Random random = new Random(); IInterpolator interpolator = new LinearInterpolator(); coords = new int[snow_flake_count][]; drawables.Clear(); for (int i = 0; i < snow_flake_count; i++) { //Console.WriteLine ("Add animation for number " + i); Animation animation = new TranslateAnimation(0, height / 10 - random.Next(height / 5), 0, height + 50); animation.Duration = (10 * height + random.Next(10 * height)) + 3000; animation.RepeatCount = -1; animation.Initialize(10, 10, 10, 10); animation.Interpolator = interpolator; coords[i] = new int[] { random.Next(width - 30), -40 }; //Console.WriteLine ("Coords = " + coords[i][0] + " and " + coords[i][1]); var snow = GetSnowFlake(); snow.SetAlpha(random.Next(180, 255)); drawables.Add(new AnimateDrawable(snow, animation)); animation.StartOffset = random.Next(20 * height); animation.StartNow(); } }
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(); } }
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); }
/// <summary> /// Hides the search bar. /// </summary> private void HideSearchBar() { _searchBarIsVisible = false; var searchAnim = new TranslateAnimation(_searchText.GetX(), _searchText.GetX(), _searchText.GetY(), -_scrollDistance) { Duration = 100, FillAfter = true }; var countAnim = new TranslateAnimation(_countText.GetX(), _countText.GetX(), _countText.GetY(), -_countText.Height) { Duration = 100, FillAfter = true }; _searchText.StartAnimation(searchAnim); _searchText.Visibility = ViewStates.Gone; _countText.StartAnimation(countAnim); _countText.Visibility = ViewStates.Gone; var anim = new TranslateAnimation(_listview.GetX(), _listview.GetX(), _listview.GetY(), _searchText.GetY()) { Duration = 50, FillAfter = true }; _listview.StartAnimation(anim); }
/** * Animate a view between start and end X/Y locations, using either old (pre-3.0) or * new animation APIs. */ private void moveView(View view, float startX, float endX, float startY, float endY, Runnable endAction) { Runnable finalEndAction = endAction; if (isRuntimePostGingerbread()) { view.Animate().SetDuration(MOVE_DURATION); if (startX != endX) { ObjectAnimator anim = ObjectAnimator.OfFloat(view, View.X, startX, endX); anim.SetDuration(MOVE_DURATION); anim.Start(); setAnimatorEndAction(anim, endAction); endAction = null; } if (startY != endY) { ObjectAnimator anim = ObjectAnimator.OfFloat(view, View.Y, startY, endY); anim.SetDuration(MOVE_DURATION); anim.Start(); setAnimatorEndAction(anim, endAction); } } else { TranslateAnimation translator = new TranslateAnimation(startX, endX, startY, endY); translator.Duration = (MOVE_DURATION); view.StartAnimation(translator); if (endAction != null) { view.Animation.SetAnimationListener(new CustomAnimatonListenerAdapter(finalEndAction)); } } }
/// <summary> /// Shows the search bar. /// </summary> private void ShowSearchBar() { _searchBarIsVisible = true; var anim = new TranslateAnimation(_listview.GetX(), _listview.GetX(), _listview.GetY(), 0) { Duration = 50, FillAfter = true }; _listview.StartAnimation(anim); _searchText.Visibility = ViewStates.Visible; _countText.Visibility = ViewStates.Visible; var searchAnim = new TranslateAnimation(_searchText.GetX(), _searchText.GetX(), _searchText.GetY(), 0) { Duration = 50, FillBefore = true }; _searchText.StartAnimation(searchAnim); var countAnim = new TranslateAnimation(_countText.GetX(), _countText.GetX(), _countText.GetY(), 0) { Duration = 50, FillBefore = true }; _countText.StartAnimation(countAnim); }
public override void HandleMessage(Message msg) { base.HandleMessage(msg); if (msg.What == 0x123) { // 横向上一直向右飞 if (m.nextX > 320) { m.curX = m.nextX = 0; } else { m.nextX += 8; } } // 纵向上可以随机上下 m.nextY = m.curY + (float)(r.NextDouble() * 10 - 5); // 设置显示蝴蝶的ImageView发生位移改变 TranslateAnimation anim = new TranslateAnimation(m.curX, m.nextX, m.curY, m.nextY); m.curX = m.nextX; m.curY = m.nextY; anim.Duration = 200; // 开始位移动画 m.imageView.StartAnimation(anim); }
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); }
private void InitView() { //设置标题栏 var img_header_back = FindViewById <ImageView> (Resource.Id.img_header_back); img_header_back.Click += (sender, e) => { this.Finish(); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); }; var tv_back = FindViewById <TextView> (Resource.Id.tv_back); tv_back.Text = "返回"; var tv_desc = FindViewById <TextView> (Resource.Id.tv_desc); tv_desc.Text = "投诉建议"; InitWidth(); InitTabBtnView(); InitViewPager(); TranslateAnimation animation = new TranslateAnimation(position_one, offset, 0, 0) { FillAfter = true, Duration = 300 }; ivBottomLine.StartAnimation(animation); }
protected override async void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { if (requestCode == 200 && resultCode == Result.Ok) { int hour = data.GetIntExtra("hour", 0); int minute = data.GetIntExtra("minute", 0); DateTime?scheduledTime = DateTime.Today; if (hour == 0 && minute == 0) { scheduledTime = null; } else { scheduledTime = scheduledTime?.AddHours(hour).AddMinutes(minute); } long healthServiceId = data.GetLongExtra("serviceId", 0); string token = SettingsHelper.GetToken(this); appState = AppState.Searching; Picasso.With(this).Load(Resource.Drawable.button_searching).Into(btnGo); pulsator.Visibility = ViewStates.Visible; helpView.SetText(Resource.String.searching); Animation animation = new TranslateAnimation(0, 0, 0, 250); animation.Duration = 300; animation.FillAfter = true; helpView.StartAnimation(animation); pulsator.Stop(); pulsator.Start(); double latitude = -6.791992, longitude = 39.208219; if (_currentLocation != null) { latitude = _currentLocation.Latitude; longitude = _currentLocation.Longitude; } ServiceRequest request = new ServiceRequest() { Latitude = latitude, Longitude = longitude, Status = RequestStatus.Initiated, HealthServiceId = healthServiceId, ScheduledTime = scheduledTime }; requestId = await ServiceHelper.LogRequest(token, request); if (requestId > 0) { //timer = new Timer(2000); //timer.Elapsed += Timer_Elapsed; //timer.Start(); } } base.OnActivityResult(requestCode, resultCode, data); }
/** * 晃动动画 * @param counts 1秒钟晃动多少下 * @return */ public static Animation shakeAnimation(int counts) { Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0); translateAnimation.Interpolator = new CycleInterpolator(counts); translateAnimation.Duration = 1000; return(translateAnimation); }
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); }
private void SelectAnimation(RelativeLayout icon) { TranslateAnimation tAnim = new TranslateAnimation(0, 0, 150, 0); tAnim.Duration = 200; tAnim.Interpolator = new LinearInterpolator(); icon.StartAnimation(tAnim); }
private Animation CreateTranslateAnimation(float fromX, float toX) { TranslateAnimation anim = new TranslateAnimation(Dimension.RelativeToParent, fromX, Dimension.RelativeToParent, toX, Dimension.RelativeToParent, 0f, Dimension.RelativeToParent, 0f); anim.Duration = 500; anim.Interpolator = new Android.Views.Animations.DecelerateInterpolator(); return(anim); }
// 初始化上下回弹的动画效果 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; }
public void AnimateIris(LinearLayout iris) { Rect corners = new Rect(); bool i = iris.GetLocalVisibleRect(corners); Animation anim = new TranslateAnimation(10, 10, corners.Top, -2550); anim.Duration = 2000; iris.StartAnimation(anim); }
public static Animation createItemInAnimation(Context context, int index, long expandDuration, int x, int y) { RotateAnimation rotate = new RotateAnimation(720, 0, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); rotate.SetInterpolator(context, Resource.Animation.sat_item_in_rotate_interpolator); rotate.Duration = expandDuration; TranslateAnimation translate = new TranslateAnimation(x, 0, y, 0); long delay = 250; if (expandDuration <= 250) { delay = expandDuration / 3; } long duration = 400; if ((expandDuration - delay) > duration) { duration = expandDuration - delay; } translate.Duration = duration; translate.StartOffset = delay; translate.SetInterpolator(context, Resource.Animation.sat_item_anticipate_interpolator); AlphaAnimation alphaAnimation = new AlphaAnimation(1f, 0f); long alphaDuration = 10; if (expandDuration < 10) { alphaDuration = expandDuration / 10; } alphaAnimation.Duration = alphaDuration; alphaAnimation.StartOffset = (delay + duration) - alphaDuration; AnimationSet animationSet = new AnimationSet(false); animationSet.FillAfter = false; animationSet.FillBefore = true; animationSet.FillEnabled = true; animationSet.AddAnimation(alphaAnimation); animationSet.AddAnimation(rotate); animationSet.AddAnimation(translate); animationSet.StartOffset = 30 * index; animationSet.Start(); animationSet.StartNow(); return(animationSet); }
private Animation CreateTranslationInAnimation() { var type = Dimension.RelativeToSelf; var an = new TranslateAnimation(type, 0, type, 0, type, 1, type, 0); an.Duration = TRANSLATE_DURATION; return(an); }
private void CreateMoveToAnimation(GameObject o, Vector3 start, Vector3 mid, Vector3 end, Vector3 startRotation, Vector3 endRotation, float startTime) { var step1 = new TranslateAnimation(o, start, mid, startTime + Random.value * 0.5f, 1f, Ease.Linear); var step2 = new TranslateAnimation(o, mid, end, step1.EndTime, 1f, Ease.InverseSquare); var q0 = Quaternion.Euler(startRotation); var q1 = Quaternion.Euler(endRotation); var rot = new RotateAnimation(o, q0, q1, step1.StartTime, 1.5f, Ease.InverseSquare); m_animations.Add(step1); m_animations.Add(step2); m_animations.Add(rot); }