Java Code Examples for android.view.View#getTranslationX()
The following examples show how to use
android.view.View#getTranslationX() .
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: adt-leanback-support File: ColorOverlayDimmer.java License: Apache License 2.0 | 6 votes |
/** * Draw a dim color overlay on top of a child View inside the canvas of * the parent View. * * @param c Canvas of the parent View. * @param v A child of the parent View. * @param includePadding Set to true to draw overlay on padding area of the * View. */ public void drawColorOverlay(Canvas c, View v, boolean includePadding) { c.save(); float dx = v.getLeft() + v.getTranslationX(); float dy = v.getTop() + v.getTranslationY(); c.translate(dx, dy); c.concat(v.getMatrix()); c.translate(-dx, -dy); if (includePadding) { c.drawRect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom(), mPaint); } else { c.drawRect(v.getLeft() + v.getPaddingLeft(), v.getTop() + v.getPaddingTop(), v.getRight() - v.getPaddingRight(), v.getBottom() - v.getPaddingBottom(), mPaint); } c.restore(); }
Example 2
Source Project: UltimateAndroid File: FreeFlowContainer.java License: Apache License 2.0 | 6 votes |
/** * Returns the actual frame for a view as its on stage. The FreeFlowItem's * frame object always represents the position it wants to be in but actual * frame may be different based on animation etc. * * @param freeflowItem * The freeflowItem to get the <code>Frame</code> for * @return The Frame for the freeflowItem or null if that view doesn't exist */ public Rect getActualFrame(final FreeFlowItem freeflowItem) { View v = freeflowItem.view; if (v == null) { return null; } Rect of = new Rect(); of.left = (int) (v.getLeft() + v.getTranslationX()); of.top = (int) (v.getTop() + v.getTranslationY()); of.right = (int) (v.getRight() + v.getTranslationX()); of.bottom = (int) (v.getBottom() + v.getTranslationY()); return of; }
Example 3
Source Project: Phonograph File: ViewUtil.java License: GNU General Public License v3.0 | 5 votes |
public static boolean hitTest(View v, int x, int y) { final int tx = (int) (v.getTranslationX() + 0.5f); final int ty = (int) (v.getTranslationY() + 0.5f); final int left = v.getLeft() + tx; final int right = v.getRight() + tx; final int top = v.getTop() + ty; final int bottom = v.getBottom() + ty; return (x >= left) && (x <= right) && (y >= top) && (y <= bottom); }
Example 4
Source Project: SwipeBack File: ViewHelper.java License: Apache License 2.0 | 5 votes |
public static int getRight(View v) { if (SwipeBack.USE_TRANSLATIONS) { return (int) (v.getRight() + v.getTranslationX()); } return v.getRight(); }
Example 5
Source Project: Transitions-Everywhere File: Explode.java License: Apache License 2.0 | 5 votes |
@Override public Animator onDisappear(@NonNull ViewGroup sceneRoot, @NonNull View view, @Nullable TransitionValues startValues, @Nullable TransitionValues endValues) { if (startValues == null) { return null; } Rect bounds = (Rect) startValues.values.get(PROPNAME_SCREEN_BOUNDS); int viewPosX = bounds.left; int viewPosY = bounds.top; float startX = view.getTranslationX(); float startY = view.getTranslationY(); float endX = startX; float endY = startY; int[] interruptedPosition = (int[]) startValues.view.getTag(R.id.transitionPosition); if (interruptedPosition != null) { // We want to have the end position relative to the interrupted position, not // the position it was supposed to start at. endX += interruptedPosition[0] - bounds.left; endY += interruptedPosition[1] - bounds.top; bounds.offsetTo(interruptedPosition[0], interruptedPosition[1]); } calculateOut(sceneRoot, bounds, mTempLoc); endX += mTempLoc[0]; endY += mTempLoc[1]; return TranslationAnimationCreator.createAnimation(view, startValues, viewPosX, viewPosY, startX, startY, endX, endY, sAccelerate, this); }
Example 6
Source Project: android_9.0.0_r45 File: ChangeTransform.java License: Apache License 2.0 | 5 votes |
public Transforms(View view) { translationX = view.getTranslationX(); translationY = view.getTranslationY(); translationZ = view.getTranslationZ(); scaleX = view.getScaleX(); scaleY = view.getScaleY(); rotationX = view.getRotationX(); rotationY = view.getRotationY(); rotationZ = view.getRotation(); }
Example 7
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 8
Source Project: Transitions-Everywhere File: Slide.java License: Apache License 2.0 | 5 votes |
@Override public float getGoneX(@NonNull ViewGroup sceneRoot, @NonNull View view) { final boolean isRtl = ViewUtils.isRtl(sceneRoot); final float x; if (isRtl) { x = view.getTranslationX() - sceneRoot.getWidth(); } else { x = view.getTranslationX() + sceneRoot.getWidth(); } return x; }
Example 9
Source Project: zhangshangwuda File: ViewHelper.java License: Apache License 2.0 | 5 votes |
public static int getRight(View v) { if (MenuDrawer.USE_TRANSLATIONS) { return (int) (v.getRight() + v.getTranslationX()); } return v.getRight(); }
Example 10
Source Project: opentasks File: BaseTaskViewDescriptor.java License: Apache License 2.0 | 5 votes |
@SuppressLint("NewApi") protected void resetFlingView(View view) { View flingContentView = getView(view, getFlingContentViewId()); if (flingContentView == null) { flingContentView = view; } if (flingContentView.getTranslationX() != 0) { flingContentView.setTranslationX(0); flingContentView.setAlpha(1); } }
Example 11
Source Project: Auie File: UEViewHelper.java License: GNU General Public License v2.0 | 4 votes |
static float getTranslationX(View view) { return view.getTranslationX(); }
Example 12
Source Project: Transitions-Everywhere File: Translation.java License: Apache License 2.0 | 4 votes |
@Override public PointF get(@NonNull View object) { return new PointF(object.getTranslationX(), object.getTranslationY()); }
Example 13
Source Project: RecyclerViewExtensions File: DragDropHelper.java License: MIT License | 4 votes |
private int getViewCenterX(View view) { return view.getLeft() + view.getWidth() / 2 + (int) view.getTranslationX(); }
Example 14
Source Project: Transitions-Everywhere File: TranslationTransition.java License: Apache License 2.0 | 4 votes |
@Override public PointF get(@NonNull View object) { return new PointF(object.getTranslationX(), object.getTranslationY()); }
Example 15
Source Project: screenshot-tests-for-android File: LayoutHierarchyDumper.java License: Apache License 2.0 | 4 votes |
public static int getViewLeft(View view) { if (Build.VERSION.SDK_INT >= 11) { return view.getLeft() + (int) view.getTranslationX(); } return view.getLeft(); }
Example 16
Source Project: Mover File: ViewHelper.java License: Apache License 2.0 | 4 votes |
static float getTranslationX(View view) { return view.getTranslationX(); }
Example 17
Source Project: KJFrameForAndroid File: ViewHelper.java License: Apache License 2.0 | 4 votes |
static float getTranslationX(View view) { return view.getTranslationX(); }
Example 18
Source Project: Telegram File: FilterUsersActivity.java License: GNU General Public License v2.0 | 4 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int count = getChildCount(); int width = MeasureSpec.getSize(widthMeasureSpec); int maxWidth = width - AndroidUtilities.dp(26); int currentLineWidth = 0; int y = AndroidUtilities.dp(10); int allCurrentLineWidth = 0; int allY = AndroidUtilities.dp(10); int x; for (int a = 0; a < count; a++) { View child = getChildAt(a); if (!(child instanceof GroupCreateSpan)) { continue; } child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(32), MeasureSpec.EXACTLY)); if (child != removingSpan && currentLineWidth + child.getMeasuredWidth() > maxWidth) { y += child.getMeasuredHeight() + AndroidUtilities.dp(8); currentLineWidth = 0; } if (allCurrentLineWidth + child.getMeasuredWidth() > maxWidth) { allY += child.getMeasuredHeight() + AndroidUtilities.dp(8); allCurrentLineWidth = 0; } x = AndroidUtilities.dp(13) + currentLineWidth; if (!animationStarted) { if (child == removingSpan) { child.setTranslationX(AndroidUtilities.dp(13) + allCurrentLineWidth); child.setTranslationY(allY); } else if (removingSpan != null) { if (child.getTranslationX() != x) { animators.add(ObjectAnimator.ofFloat(child, View.TRANSLATION_X, x)); } if (child.getTranslationY() != y) { animators.add(ObjectAnimator.ofFloat(child, View.TRANSLATION_Y, y)); } } else { child.setTranslationX(x); child.setTranslationY(y); } } if (child != removingSpan) { currentLineWidth += child.getMeasuredWidth() + AndroidUtilities.dp(9); } allCurrentLineWidth += child.getMeasuredWidth() + AndroidUtilities.dp(9); } int minWidth; if (AndroidUtilities.isTablet()) { minWidth = AndroidUtilities.dp(530 - 26 - 18 - 57 * 2) / 3; } else { minWidth = (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(26 + 18 + 57 * 2)) / 3; } if (maxWidth - currentLineWidth < minWidth) { currentLineWidth = 0; y += AndroidUtilities.dp(32 + 8); } if (maxWidth - allCurrentLineWidth < minWidth) { allY += AndroidUtilities.dp(32 + 8); } editText.measure(MeasureSpec.makeMeasureSpec(maxWidth - currentLineWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(32), MeasureSpec.EXACTLY)); if (!animationStarted) { int currentHeight = allY + AndroidUtilities.dp(32 + 10); int fieldX = currentLineWidth + AndroidUtilities.dp(16); fieldY = y; if (currentAnimation != null) { int resultHeight = y + AndroidUtilities.dp(32 + 10); if (containerHeight != resultHeight) { animators.add(ObjectAnimator.ofInt(FilterUsersActivity.this, "containerHeight", resultHeight)); } if (editText.getTranslationX() != fieldX) { animators.add(ObjectAnimator.ofFloat(editText, View.TRANSLATION_X, fieldX)); } if (editText.getTranslationY() != fieldY) { animators.add(ObjectAnimator.ofFloat(editText, View.TRANSLATION_Y, fieldY)); } editText.setAllowDrawCursor(false); currentAnimation.playTogether(animators); currentAnimation.start(); animationStarted = true; } else { containerHeight = currentHeight; editText.setTranslationX(fieldX); editText.setTranslationY(fieldY); } } else if (currentAnimation != null) { if (!ignoreScrollEvent && removingSpan == null) { editText.bringPointIntoView(editText.getSelectionStart()); } } setMeasuredDimension(width, containerHeight); }
Example 19
Source Project: NotificationPeekPort File: SwipeHelper.java License: Apache License 2.0 | 4 votes |
private float getTranslation(View v) { return mSwipeDirection == X ? v.getTranslationX() : v.getTranslationY(); }
Example 20
Source Project: TelePlus-Android File: InviteContactsActivity.java License: GNU General Public License v2.0 | 4 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int count = getChildCount(); int width = MeasureSpec.getSize(widthMeasureSpec); int maxWidth = width - AndroidUtilities.dp(32); int currentLineWidth = 0; int y = AndroidUtilities.dp(12); int allCurrentLineWidth = 0; int allY = AndroidUtilities.dp(12); int x; for (int a = 0; a < count; a++) { View child = getChildAt(a); if (!(child instanceof GroupCreateSpan)) { continue; } child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(32), MeasureSpec.EXACTLY)); if (child != removingSpan && currentLineWidth + child.getMeasuredWidth() > maxWidth) { y += child.getMeasuredHeight() + AndroidUtilities.dp(12); currentLineWidth = 0; } if (allCurrentLineWidth + child.getMeasuredWidth() > maxWidth) { allY += child.getMeasuredHeight() + AndroidUtilities.dp(12); allCurrentLineWidth = 0; } x = AndroidUtilities.dp(16) + currentLineWidth; if (!animationStarted) { if (child == removingSpan) { child.setTranslationX(AndroidUtilities.dp(16) + allCurrentLineWidth); child.setTranslationY(allY); } else if (removingSpan != null) { if (child.getTranslationX() != x) { animators.add(ObjectAnimator.ofFloat(child, "translationX", x)); } if (child.getTranslationY() != y) { animators.add(ObjectAnimator.ofFloat(child, "translationY", y)); } } else { child.setTranslationX(x); child.setTranslationY(y); } } if (child != removingSpan) { currentLineWidth += child.getMeasuredWidth() + AndroidUtilities.dp(9); } allCurrentLineWidth += child.getMeasuredWidth() + AndroidUtilities.dp(9); } int minWidth; if (AndroidUtilities.isTablet()) { minWidth = AndroidUtilities.dp(530 - 32 - 18 - 57 * 2) / 3; } else { minWidth = (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(32 + 18 + 57 * 2)) / 3; } if (maxWidth - currentLineWidth < minWidth) { currentLineWidth = 0; y += AndroidUtilities.dp(32 + 12); } if (maxWidth - allCurrentLineWidth < minWidth) { allY += AndroidUtilities.dp(32 + 12); } editText.measure(MeasureSpec.makeMeasureSpec(maxWidth - currentLineWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(32), MeasureSpec.EXACTLY)); if (!animationStarted) { int currentHeight = allY + AndroidUtilities.dp(32 + 12); int fieldX = currentLineWidth + AndroidUtilities.dp(16); fieldY = y; if (currentAnimation != null) { int resultHeight = y + AndroidUtilities.dp(32 + 12); if (containerHeight != resultHeight) { animators.add(ObjectAnimator.ofInt(InviteContactsActivity.this, "containerHeight", resultHeight)); } if (editText.getTranslationX() != fieldX) { animators.add(ObjectAnimator.ofFloat(editText, "translationX", fieldX)); } if (editText.getTranslationY() != fieldY) { animators.add(ObjectAnimator.ofFloat(editText, "translationY", fieldY)); } editText.setAllowDrawCursor(false); currentAnimation.playTogether(animators); currentAnimation.start(); animationStarted = true; } else { containerHeight = currentHeight; editText.setTranslationX(fieldX); editText.setTranslationY(fieldY); } } else if (currentAnimation != null) { if (!ignoreScrollEvent && removingSpan == null) { editText.bringPointIntoView(editText.getSelectionStart()); } } setMeasuredDimension(width, containerHeight); }