Java Code Examples for androidx.core.view.ViewCompat#setTranslationY()

The following examples show how to use androidx.core.view.ViewCompat#setTranslationY() . 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 File: ViewPagerTabFragmentParentFragment.java    From UltimateRecyclerView with Apache License 2.0 6 votes vote down vote up
@Override
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
    if (dragging) {
        int headerBannerHeight = headerBanner.getHeight();
        float currentHeaderTranslationY = ViewCompat.getTranslationY(mHeaderContainer);
        if (firstScroll) {
            if (-headerBannerHeight < currentHeaderTranslationY) {
                mBaseTranslationY = scrollY;
            }
        }
        final float headerTranslationY = ScrollUtils.getFloat(mBaseTranslationY - scrollY, -headerBannerHeight, 0);
        ViewCompat.animate(mHeaderContainer).cancel();
        ViewCompat.setTranslationY(mHeaderContainer, headerTranslationY);
        //todo: need some more works on this
        setpagertoppadding(totalfullheight - headerTranslationY);
    }
}
 
Example 2
Source File: BaseItemAnimator.java    From recyclerview-animators with Apache License 2.0 6 votes vote down vote up
@Override
public boolean animateMove(final ViewHolder holder, int fromX, int fromY, int toX, int toY) {
  final View view = holder.itemView;
  fromX += ViewCompat.getTranslationX(holder.itemView);
  fromY += ViewCompat.getTranslationY(holder.itemView);
  endAnimation(holder);
  int deltaX = toX - fromX;
  int deltaY = toY - fromY;
  if (deltaX == 0 && deltaY == 0) {
    dispatchMoveFinished(holder);
    return false;
  }
  if (deltaX != 0) {
    ViewCompat.setTranslationX(view, -deltaX);
  }
  if (deltaY != 0) {
    ViewCompat.setTranslationY(view, -deltaY);
  }
  mPendingMoves.add(new MoveInfo(holder, fromX, fromY, toX, toY));
  return true;
}
 
Example 3
Source File: BaseItemAnimator.java    From recyclerview-animators with Apache License 2.0 6 votes vote down vote up
private boolean endChangeAnimationIfNecessary(ChangeInfo changeInfo, ViewHolder item) {
  boolean oldItem = false;
  if (changeInfo.newHolder == item) {
    changeInfo.newHolder = null;
  } else if (changeInfo.oldHolder == item) {
    changeInfo.oldHolder = null;
    oldItem = true;
  } else {
    return false;
  }
  ViewCompat.setAlpha(item.itemView, 1);
  ViewCompat.setTranslationX(item.itemView, 0);
  ViewCompat.setTranslationY(item.itemView, 0);
  dispatchChangeFinished(item, oldItem);
  return true;
}
 
Example 4
Source File: PendingItemAnimator.java    From FlexibleAdapter with Apache License 2.0 6 votes vote down vote up
/**
 * Do whatever you need to do before animation.
 **/
protected boolean prepHolderForAnimateMove(final H holder, int fromX, int fromY, int toX, int toY) {
    final View view = holder.itemView;
    int deltaX = toX - fromX;
    int deltaY = toY - fromY;
    if (deltaX == 0 && deltaY == 0) {
        dispatchMoveFinished(holder);
        return false;
    }
    if (deltaX != 0) {
        ViewCompat.setTranslationX(view, -deltaX);
    }
    if (deltaY != 0) {
        ViewCompat.setTranslationY(view, -deltaY);
    }
    return true;
}
 
Example 5
Source File: SlidingPanelLayout.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
/**
 * Update the parallax based on the current slide offset.
 */
@SuppressLint("NewApi")
private void applyParallaxForCurrentSlideOffset() {
    if (mParallaxOffset > 0) {
        int mainViewOffset = getCurrentParallaxOffset();
        ViewCompat.setTranslationY(mMainView, mainViewOffset);
    }
}
 
Example 6
Source File: PendingItemAnimator.java    From FlexibleAdapter with Apache License 2.0 5 votes vote down vote up
@Override
public void endAnimation(ViewHolder item) {
    final View view = item.itemView;
    ViewCompat.animate(view).cancel();
    if (mPendingMoves.contains(item)) {
        ViewCompat.setTranslationY(view, 0);
        ViewCompat.setTranslationX(view, 0);
        dispatchMoveFinished(item);
        mPendingMoves.remove(item);
    }
    if (mPendingRemovals.contains(item)) {
        dispatchRemoveFinished(item);
        mPendingRemovals.remove(item);
    }
    if (mPendingAdditions.contains(item)) {
        dispatchAddFinished(item);
        mPendingAdditions.remove(item);
    }
    if (mMoveAnimations.contains(item)) {
        ViewCompat.setTranslationY(view, 0);
        ViewCompat.setTranslationX(view, 0);
        dispatchMoveFinished(item);
        mMoveAnimations.remove(item);
    }
    if (mRemoveAnimations.contains(item)) {
        dispatchRemoveFinished(item);
        mRemoveAnimations.remove(item);
    }
    if (mAddAnimations.contains(item)) {
        dispatchAddFinished(item);
        mAddAnimations.remove(item);
    }
    dispatchFinishedWhenDone();
}
 
Example 7
Source File: SlidingUpPanelLayout.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
/**
 * Update the parallax based on the current slide offset.
 */
@SuppressLint("NewApi")
private void applyParallaxForCurrentSlideOffset() {
    if (mParallaxOffset > 0) {
        int mainViewOffset = getCurrentParallaxOffset();
        ViewCompat.setTranslationY(mMainView, mainViewOffset);
    }
}
 
Example 8
Source File: VibrationModeView.java    From prayer-times-android with Apache License 2.0 5 votes vote down vote up
public VibrationModeView(@NonNull Context c, AttributeSet attrs, int defStyle) {
    super(c, attrs, defStyle);
    mDrawable = c.getResources().getDrawable(R.drawable.ic_vibration_white_24dp);
    setOnClickListener(this);

    ViewCompat.setTranslationY(this, getResources().getDimension(R.dimen.dimen4dp));

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
}
 
Example 9
Source File: VibrationModeView.java    From prayer-times-android with Apache License 2.0 5 votes vote down vote up
public VibrationModeView(@NonNull Context c, AttributeSet attrs, int defStyle) {
    super(c, attrs, defStyle);
    mDrawable = c.getResources().getDrawable(R.drawable.ic_vibration_white_24dp);
    setOnClickListener(this);

    ViewCompat.setTranslationY(this, getResources().getDimension(R.dimen.dimen4dp));

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
}
 
Example 10
Source File: SlideInDownAnimator.java    From recyclerview-animators with Apache License 2.0 4 votes vote down vote up
@Override protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
  ViewCompat.setTranslationY(holder.itemView, -holder.itemView.getHeight());
  ViewCompat.setAlpha(holder.itemView, 0);
}
 
Example 11
Source File: ItemTouchUIUtilImpl.java    From monero-wallet-android-app with MIT License 4 votes vote down vote up
@Override
public void clearView(View view) {
    ViewCompat.setTranslationX(view, 0f);
    ViewCompat.setTranslationY(view, 0f);
}
 
Example 12
Source File: FadeInDownAnimator.java    From recyclerview-animators with Apache License 2.0 4 votes vote down vote up
@Override protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
  ViewCompat.setTranslationY(holder.itemView, -holder.itemView.getHeight() * .25f);
  ViewCompat.setAlpha(holder.itemView, 0);
}
 
Example 13
Source File: PendingItemAnimator.java    From FlexibleAdapter with Apache License 2.0 4 votes vote down vote up
/**
 * This should reset the move animation.
 **/
protected void onMoveCanceled(ViewHolder holder) {
    ViewCompat.setTranslationX(holder.itemView, 0);
    ViewCompat.setTranslationY(holder.itemView, 0);
}
 
Example 14
Source File: FromTopItemAnimator.java    From FlexibleAdapter with Apache License 2.0 4 votes vote down vote up
@Override
protected void onAddCanceled(ViewHolder holder) {
    ViewCompat.setTranslationY(holder.itemView, 0);
}
 
Example 15
Source File: FromTopItemAnimator.java    From FlexibleAdapter with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean prepHolderForAnimateAdd(ViewHolder holder) {
    int bottom = holder.itemView.getBottom();
    ViewCompat.setTranslationY(holder.itemView, -bottom);
    return true;
}
 
Example 16
Source File: FromTopItemAnimator.java    From FlexibleAdapter with Apache License 2.0 4 votes vote down vote up
@Override
protected void onRemoveCanceled(ViewHolder holder) {
    ViewCompat.setTranslationY(holder.itemView, 0);
}
 
Example 17
Source File: FadeInUpAnimator.java    From recyclerview-animators with Apache License 2.0 4 votes vote down vote up
@Override protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
  ViewCompat.setTranslationY(holder.itemView, holder.itemView.getHeight() * .25f);
  ViewCompat.setAlpha(holder.itemView, 0);
}
 
Example 18
Source File: ItemTouchUIUtilImpl.java    From CrazyDaily with Apache License 2.0 4 votes vote down vote up
@Override
public void onDraw(Canvas c, RecyclerView recyclerView, View view,
                   float dX, float dY, int actionState, boolean isCurrentlyActive) {
    ViewCompat.setTranslationX(view, dX);
    ViewCompat.setTranslationY(view, dY);
}
 
Example 19
Source File: ItemTouchUIUtilImpl.java    From CrazyDaily with Apache License 2.0 4 votes vote down vote up
@Override
public void clearView(View view) {
    ViewCompat.setTranslationX(view, 0f);
    ViewCompat.setTranslationY(view, 0f);
}
 
Example 20
Source File: ItemTouchUIUtilImpl.java    From monero-wallet-android-app with MIT License 4 votes vote down vote up
@Override
public void onDraw(Canvas c, RecyclerView recyclerView, View view,
                   float dX, float dY, int actionState, boolean isCurrentlyActive) {
    ViewCompat.setTranslationX(view, dX);
    ViewCompat.setTranslationY(view, dY);
}