List of usage examples for android.view View getTranslationY
@ViewDebug.ExportedProperty(category = "drawing") public float getTranslationY()
From source file:Main.java
public static ObjectAnimator tranY(View view, int duration, float pos) { float currentY = view.getTranslationY(); ObjectAnimator animator = ObjectAnimator.ofFloat(view, TRANSLATION_Y, pos, currentY); return animator.setDuration(duration); }
From source file:org.chromium.chrome.browser.physicalweb.ListUrlsActivity.java
private static Animator createTranslationYAnimator(View view, float endValue, long durationMillis) { return ObjectAnimator.ofFloat(view, "translationY", view.getTranslationY(), endValue) .setDuration(durationMillis); }
From source file:com.facebook.litho.utils.IncrementalMountUtils.java
private static void maybePerformIncrementalMountOnView(int scrollingParentWidth, int scrollingParentHeight, View view) { final View underlyingView = view instanceof WrapperView ? ((WrapperView) view).getWrappedView() : view; if (!(underlyingView instanceof LithoView)) { return;/*from w ww. j a v a 2s .co m*/ } final LithoView lithoView = (LithoView) underlyingView; if (!lithoView.isIncrementalMountEnabled()) { return; } if (view != underlyingView && view.getHeight() != underlyingView.getHeight()) { throw new IllegalStateException( "ViewDiagnosticsWrapper must be the same height as the underlying view"); } final int translationX = (int) view.getTranslationX(); final int translationY = (int) view.getTranslationY(); final int top = view.getTop() + translationY; final int bottom = view.getBottom() + translationY; final int left = view.getLeft() + translationX; final int right = view.getRight() + translationX; if (left >= 0 && top >= 0 && right <= scrollingParentWidth && bottom <= scrollingParentHeight && lithoView.getPreviousMountBounds().width() == lithoView.getWidth() && lithoView.getPreviousMountBounds().height() == lithoView.getHeight()) { // View is fully visible, and has already been completely mounted. return; } final Rect rect = acquireRect(); rect.set(Math.max(0, -left), Math.max(0, -top), Math.min(right, scrollingParentWidth) - left, Math.min(bottom, scrollingParentHeight) - top); if (rect.isEmpty()) { // View is not visible at all, nothing to do. release(rect); return; } lithoView.performIncrementalMount(rect); release(rect); }
From source file:com.dbychkov.words.behavior.ScrollOffBottomBehavior.java
@Override public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency) { float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight()); child.setTranslationY(translationY); return true;/*from w w w. j av a2s.c om*/ }
From source file:nl.eduvpn.app.utils.SwipeToDeleteAnimator.java
@Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { // only if animation is in progress if (parent.getItemAnimator().isRunning()) { // some items might be animating down and some items might be animating up to close the gap left by the removed item // this is not exclusive, both movement can be happening at the same time // to reproduce this leave just enough items so the first one and the last one would be just a little off screen // then remove one from the middle // find first child with translationY > 0 // and last one with translationY < 0 // we're after a rect that is not covered in recycler-view views at this point in time View lastViewComingDown = null; View firstViewComingUp = null; // this is fixed int left = 0; int right = parent.getWidth(); // this we need to find out int top = 0; int bottom = 0; // find relevant translating views int childCount = parent.getLayoutManager().getChildCount(); for (int i = 0; i < childCount; i++) { View child = parent.getLayoutManager().getChildAt(i); if (child.getTranslationY() < 0) { // view is coming down lastViewComingDown = child; } else if (child.getTranslationY() > 0) { // view is coming up if (firstViewComingUp == null) { firstViewComingUp = child; }/*from w ww.java2 s . co m*/ } } if (lastViewComingDown != null && firstViewComingUp != null) { // views are coming down AND going up to fill the void top = lastViewComingDown.getBottom() + (int) lastViewComingDown.getTranslationY(); bottom = firstViewComingUp.getTop() + (int) firstViewComingUp.getTranslationY(); } else if (lastViewComingDown != null) { // views are going down to fill the void top = lastViewComingDown.getBottom() + (int) lastViewComingDown.getTranslationY(); bottom = lastViewComingDown.getBottom(); } else if (firstViewComingUp != null) { // views are coming up to fill the void top = firstViewComingUp.getTop(); bottom = firstViewComingUp.getTop() + (int) firstViewComingUp.getTranslationY(); } _background.setBounds(left, top, right, bottom); _background.draw(c); } super.onDraw(c, parent, state); }
From source file:net.nym.napply.library.behavior.BottomScrollShowHideBehavior.java
private void show(final View child) { if (child == null) { return;/* w w w. jav a2s .c o m*/ } final float translationY = child.getTranslationY(); //hide -> show if (translationY <= 0 || isAnimate) { return; } ViewPropertyAnimatorCompat animator = ViewCompat.animate(child); animator.translationY(0).setDuration(500).setInterpolator(new DecelerateInterpolator()) .setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(View view) { child.setVisibility(View.VISIBLE); isAnimate = true; } @Override public void onAnimationEnd(View view) { isAnimate = false; } @Override public void onAnimationCancel(View view) { hide(child); } }).start(); }
From source file:net.nym.napply.library.behavior.BottomScrollShowHideBehavior.java
private void hide(final View child) { if (child == null) { return;//from w w w .j ava2 s.co m } final float translationY = child.getTranslationY(); //show -> hide if (translationY < 0 || isAnimate) { return; } ViewPropertyAnimatorCompat animator = ViewCompat.animate(child); animator.translationY(child.getHeight()).setDuration(500).setInterpolator(new DecelerateInterpolator()) .setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(View view) { isAnimate = true; } @Override public void onAnimationEnd(View view) { child.setVisibility(View.GONE); isAnimate = false; } @Override public void onAnimationCancel(View view) { show(child); } }).start(); }
From source file:net.nym.napply.library.behavior.HeadScrollShowHideBehavior.java
private void show(final View child) { if (child == null) { return;/*from w w w. j a v a 2 s . c o m*/ } final float translationY = child.getTranslationY(); //hide -> show if (translationY >= 0 || isAnimate) { return; } ViewPropertyAnimatorCompat animator = ViewCompat.animate(child); animator.translationY(0).setDuration(500).setInterpolator(new DecelerateInterpolator()) .setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(View view) { child.setVisibility(View.VISIBLE); isAnimate = true; } @Override public void onAnimationEnd(View view) { isAnimate = false; } @Override public void onAnimationCancel(View view) { hide(child); } }).start(); }
From source file:net.nym.napply.library.behavior.HeadScrollShowHideBehavior.java
private void hide(final View child) { if (child == null) { return;// w ww .j av a 2s . co m } final float translationY = child.getTranslationY(); //show -> hide if (translationY < 0 || isAnimate) { return; } ViewPropertyAnimatorCompat animator = ViewCompat.animate(child); animator.translationY(-child.getHeight()).setDuration(500).setInterpolator(new DecelerateInterpolator()) .setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(View view) { isAnimate = true; } @Override public void onAnimationEnd(View view) { child.setVisibility(View.GONE); isAnimate = false; } @Override public void onAnimationCancel(View view) { show(child); } }).start(); }
From source file:au.com.roadhouse.licensehelper.library.VerticalDividerItemDecorator.java
@Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { RecyclerView.Adapter adapter = parent.getAdapter(); for (int i = 0; i < parent.getChildCount(); i++) { View view = parent.getChildAt(i); if (parent.getChildAdapterPosition(view) != 0 && parent.getChildAdapterPosition(view) < adapter.getItemCount()) { mDividerColorDrawable.setBounds(0, view.getTop() + (int) view.getTranslationY() - mDividerHeight, parent.getWidth(), view.getTop() + (int) view.getTranslationY()); mDividerColorDrawable.draw(c); }/* w ww. j a v a 2s. c o m*/ } }