Java Code Examples for android.view.View#getTranslationY()
The following examples show how to use
android.view.View#getTranslationY() .
These examples are extracted from open source projects.
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 Project: scene File: TranslationAnimationCreator.java License: Apache License 2.0 | 6 votes |
/** * Creates an animator that can be used for x and/or y translations. When interrupted, * it sets a tag to keep track of the position so that it may be continued from position. * * @param view The view being moved. This may be in the overlay for onDisappear. * @param values The values containing the view in the view hierarchy. * @param viewPosX The x screen coordinate of view * @param viewPosY The y screen coordinate of view * @param startX The start translation x of view * @param startY The start translation y of view * @param endX The end translation x of view * @param endY The end translation y of view * @param interpolator The interpolator to use with this animator. * @return An animator that moves from (startX, startY) to (endX, endY) unless there was * a previous interruption, in which case it moves from the current position to (endX, endY). */ static PathInteractionAnimation createAnimation(View view, int viewPosX, int viewPosY, float startX, float startY, float endX, float endY, TimeInterpolator interpolator) { float terminalX = view.getTranslationX(); float terminalY = view.getTranslationY(); // Initial position is at translation startX, startY, so position is offset by that amount int startPosX = viewPosX + Math.round(startX - terminalX); int startPosY = viewPosY + Math.round(startY - terminalY); view.setTranslationX(startX); view.setTranslationY(startY); if (startX == endX && startY == endY) { return null; } Path path = new Path(); path.moveTo(startX, startY); path.lineTo(endX, endY); return new PathInteractionAnimation(1.0f, path, view); }
Example 2
Source Project: CoordinatorLayoutExample File: GroupHeaderBehavior.java License: Apache License 2.0 | 6 votes |
@Override public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull View child, @NonNull View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type) { logD(TAG, "onNestedScroll: dyConsumed=" + dyConsumed + " dyUnconsumed= " + dyUnconsumed); if (dyUnconsumed > 0) { return; } float translationY = child.getTranslationY() - dyUnconsumed; int maxHeadTranslateY = 0; if (translationY > maxHeadTranslateY) { translationY = maxHeadTranslateY; } logD(TAG, "onNestedScroll: translationY=" + translationY); if (child.getTranslationY() != translationY) { onScrollChange(type, (int) translationY); child.setTranslationY(translationY); } }
Example 3
Source Project: BehaviorDemo File: MainHeaderBehavior.java License: Apache License 2.0 | 6 votes |
/** * 是否可以整体滑动 * * @return */ private boolean canScroll(View child, float scrollY) { if (scrollY > 0 && child.getTranslationY() > getHeaderOffset()) { return true; } if (child.getTranslationY() == getHeaderOffset() && upReach) { return true; } if (scrollY < 0 && !downReach) { return true; } return false; }
Example 4
Source Project: RecyclerViewExtensions File: StickyHeadersLinearLayoutManager.java License: MIT License | 6 votes |
/** * Returns true when the {@code view} is at the edge of the parent {@link RecyclerView}. */ private boolean isViewOnBoundary(View view) { if (getOrientation() == VERTICAL) { if (getReverseLayout()) { return view.getBottom() - view.getTranslationY() > getHeight() + mTranslationY; } else { return view.getTop() + view.getTranslationY() < mTranslationY; } } else { if (getReverseLayout()) { return view.getRight() - view.getTranslationX() > getWidth() + mTranslationX; } else { return view.getLeft() + view.getTranslationX() < mTranslationX; } } }
Example 5
Source Project: VideoOS-Android-SDK File: UDView.java License: GNU General Public License v3.0 | 5 votes |
/** * 获取TranslationY * * @return */ public float getTranslationY() { View view = getView(); if (view != null) { return view.getTranslationY(); } return 0; }
Example 6
Source Project: CoordinatorLayoutExample File: SearchBehavior.java License: Apache License 2.0 | 5 votes |
private void offsetChildAsNeeded(CoordinatorLayout parent, View child, View dependency) { int headerOffsetRange = getHeaderOffsetRange(); int titleOffsetRange = getSearchOffest(); if (BuildConfig.DEBUG) { Log.d(TAG, "offsetChildAsNeeded:" + dependency.getTranslationY()); } if (dependency.getTranslationY() == headerOffsetRange) { child.setTranslationY(titleOffsetRange); } else if (dependency.getTranslationY() == 0) { child.setTranslationY(0); } else { child.setTranslationY((int) (dependency.getTranslationY() / (headerOffsetRange * 1.0f) * titleOffsetRange)); } }
Example 7
Source Project: SwipeBack File: ViewHelper.java License: Apache License 2.0 | 5 votes |
public static int getTop(View v) { if (SwipeBack.USE_TRANSLATIONS) { return (int) (v.getTop() + v.getTranslationY()); } return v.getTop(); }
Example 8
Source Project: Mover File: ViewPropertyAnimatorHC.java License: Apache License 2.0 | 5 votes |
/** * This method gets the value of the named property from the View object. * * @param propertyConstant The property whose value should be returned * @return float The value of the named property */ private float getValue(int propertyConstant) { //final View.TransformationInfo info = mView.mTransformationInfo; View v = mView.get(); if (v != null) { switch (propertyConstant) { case TRANSLATION_X: //return info.mTranslationX; return v.getTranslationX(); case TRANSLATION_Y: //return info.mTranslationY; return v.getTranslationY(); case ROTATION: //return info.mRotation; return v.getRotation(); case ROTATION_X: //return info.mRotationX; return v.getRotationX(); case ROTATION_Y: //return info.mRotationY; return v.getRotationY(); case SCALE_X: //return info.mScaleX; return v.getScaleX(); case SCALE_Y: //return info.mScaleY; return v.getScaleY(); case X: //return v.mLeft + info.mTranslationX; return v.getX(); case Y: //return v.mTop + info.mTranslationY; return v.getY(); case ALPHA: //return info.mAlpha; return v.getAlpha(); } } return 0; }
Example 9
Source Project: LB-Launcher File: CellLayout.java License: Apache License 2.0 | 5 votes |
public ReorderPreviewAnimation(View child, int mode, int cellX0, int cellY0, int cellX1, int cellY1, int spanX, int spanY) { regionToCenterPoint(cellX0, cellY0, spanX, spanY, mTmpPoint); final int x0 = mTmpPoint[0]; final int y0 = mTmpPoint[1]; regionToCenterPoint(cellX1, cellY1, spanX, spanY, mTmpPoint); final int x1 = mTmpPoint[0]; final int y1 = mTmpPoint[1]; final int dX = x1 - x0; final int dY = y1 - y0; finalDeltaX = 0; finalDeltaY = 0; int dir = mode == MODE_HINT ? -1 : 1; if (dX == dY && dX == 0) { } else { if (dY == 0) { finalDeltaX = - dir * Math.signum(dX) * mReorderPreviewAnimationMagnitude; } else if (dX == 0) { finalDeltaY = - dir * Math.signum(dY) * mReorderPreviewAnimationMagnitude; } else { double angle = Math.atan( (float) (dY) / dX); finalDeltaX = (int) (- dir * Math.signum(dX) * Math.abs(Math.cos(angle) * mReorderPreviewAnimationMagnitude)); finalDeltaY = (int) (- dir * Math.signum(dY) * Math.abs(Math.sin(angle) * mReorderPreviewAnimationMagnitude)); } } this.mode = mode; initDeltaX = child.getTranslationX(); initDeltaY = child.getTranslationY(); finalScale = getChildrenScale() - 4.0f / child.getWidth(); initScale = child.getScaleX(); this.child = child; }
Example 10
Source Project: scene File: Slide.java License: Apache License 2.0 | 4 votes |
@Override public float getGoneY(ViewGroup sceneRoot, View view, float fraction) { return view.getTranslationY(); }
Example 11
Source Project: scene File: Slide.java License: Apache License 2.0 | 4 votes |
@Override public float getGoneY(ViewGroup sceneRoot, View view, float fraction) { return view.getTranslationY() + sceneRoot.getHeight() * fraction; }
Example 12
Source Project: KJFrameForAndroid File: ViewHelper.java License: Apache License 2.0 | 4 votes |
static float getTranslationY(View view) { return view.getTranslationY(); }
Example 13
Source Project: adt-leanback-support File: Slide.java License: Apache License 2.0 | 4 votes |
@Override public float getGone(float distance, View view) { return view.getTranslationY() - distance; }
Example 14
Source Project: LRecyclerView File: DoubleHeaderDecoration.java License: Apache License 2.0 | 4 votes |
private int getAnimatedTop(View child) { return child.getTop() + (int)child.getTranslationY(); }
Example 15
Source Project: Animer File: Animer.java License: Apache License 2.0 | 4 votes |
@Override public float getValue(View view) { return view.getTranslationY(); }
Example 16
Source Project: timecat File: ViewHelper.java License: Apache License 2.0 | 4 votes |
static float getTranslationY(View view) { return view.getTranslationY(); }
Example 17
Source Project: moviedb-android File: TVDetails.java License: Apache License 2.0 | 4 votes |
@Override public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { float scroll = scrollY; if (mViewPager.getCurrentItem() == 0) { scroll = (scroll / scrollSpeed); if (scrollY / scale >= 0 && onMoreIconClick.getKey()) onMoreIconClick.onClick(null); } if (dragging) { View toolbarView = getActivity().findViewById(R.id.toolbar); if (scroll > oldScrollY) { if (upDyKey) { upDy = scroll; upDyKey = false; } else { dy = upDy - scroll; if (dy >= -toolbarView.getHeight()) { toolbarView.setTranslationY(dy); mSlidingTabLayout.setTranslationY(dy); } else { toolbarView.setTranslationY(-toolbarView.getHeight()); mSlidingTabLayout.setTranslationY(-toolbarView.getHeight()); } downDyKey = true; } } if (scroll < oldScrollY) { if (downDyKey) { downDy = scroll; downDyTrans = toolbarView.getTranslationY(); downDyKey = false; } else { dy = (downDyTrans + (downDy - scroll)); if (dy <= 0) { toolbarView.setTranslationY(dy); mSlidingTabLayout.setTranslationY(dy); } else { toolbarView.setTranslationY(0); mSlidingTabLayout.setTranslationY(0); } upDyKey = true; } } } oldScrollY = scroll; }
Example 18
Source Project: BehaviorDemo File: XiamiTitleBehavior.java License: Apache License 2.0 | 4 votes |
@Override public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) { float y = -(1 - dependency.getTranslationY() / getHeaderOffset()) * getTitleHeight(); child.setY(y); return true; }
Example 19
Source Project: letv File: ViewCompatHC.java License: Apache License 2.0 | 4 votes |
public static float getTranslationY(View view) { return view.getTranslationY(); }
Example 20
Source Project: android-project-wo2b File: ViewHelper.java License: Apache License 2.0 | 4 votes |
static float getTranslationY(View view) { return view.getTranslationY(); }