private void SetUpBar() { LinearLayout listLayout = FindViewById <LinearLayout>(Resource.Id.ll_list); View imgBar = FindViewById <View>(Resource.Id.img_bar); int minY = 0; listLayout.ViewTreeObserver.GlobalLayout += (s, e) => { minY = (int)listLayout.GetY(); }; imgBar.Touch += (s, e) => { var handled = false; if (e.Event.Action == MotionEventActions.Down) { // do stuff yDelta = (int)(listLayout.GetY() - e.Event.RawY); handled = true; } else if (e.Event.Action == MotionEventActions.Up) { // do other stuff handled = true; } else if (e.Event.Action == MotionEventActions.Move) { if (listLayout.GetY() <= minY || e.Event.RawY + yDelta <= minY) { listLayout.Animate().Y(e.Event.RawY + yDelta).SetDuration(0).Start(); } } e.Handled = handled; }; }
protected int[] calculateCurrentCenterCoordinatesOfPagerElement(int activeElementIndex) { int y = (int)(mPagerIconsContainer.GetY() + mPagerIconsContainer.Height / 2); if (activeElementIndex >= mPagerIconsContainer.ChildCount) { return new int[] { mRootLayout.Width / 2, y } } ; View pagerElem = mPagerIconsContainer.GetChildAt(activeElementIndex); int x = (int)(mPagerIconsContainer.GetX() + pagerElem.GetX() + pagerElem.Width / 2); return(new int[] { x, y }); }
protected Animator createContentCenteringVerticalAnimation(View newContentText, View newContentIcon) { newContentText.Measure(View.MeasureSpec.MakeMeasureSpec(mContentCenteredContainer.Width, MeasureSpecMode.AtMost), -2); int measuredContentTextHeight = newContentText.MeasuredHeight; newContentIcon.Measure(-2, -2); int measuredContentIconHeight = newContentIcon.MeasuredWidth; int newHeightOfContent = measuredContentIconHeight + measuredContentTextHeight + ((ViewGroup.MarginLayoutParams)mContentTextContainer.LayoutParameters).TopMargin; Animator centerContentAnimation = ObjectAnimator.OfFloat(mContentCenteredContainer, "y", mContentCenteredContainer.GetY(), (mContentRootLayout.Height - newHeightOfContent) / 2); centerContentAnimation.SetDuration(ANIM_CONTENT_CENTERING_TIME); centerContentAnimation.SetInterpolator(new DecelerateInterpolator()); return(centerContentAnimation); }