本文整理汇总了Java中android.support.v4.view.ViewCompat.setTranslationY方法的典型用法代码示例。如果您正苦于以下问题:Java ViewCompat.setTranslationY方法的具体用法?Java ViewCompat.setTranslationY怎么用?Java ViewCompat.setTranslationY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.ViewCompat
的用法示例。
在下文中一共展示了ViewCompat.setTranslationY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performCircularReveal
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void performCircularReveal(View show) {
show.setBackgroundColor(0xffff0000);
ViewCompat.setTranslationY(show, 0);
ViewCompat.setTranslationX(show, 0);
show.getLayoutParams().height = 500;
show.getLayoutParams().width = 1920;
show.requestLayout();
int centerX = (show.getLeft() + show.getRight()) / 2;
int centerY = (show.getTop() + show.getBottom()) / 2;
float finalRadius = (float) Math.hypot((double) centerX, (double) centerY);
Animator mCircularReveal = ViewAnimationUtils.createCircularReveal(
show, centerX, centerY, 0, finalRadius);
mCircularReveal.setInterpolator(new AccelerateDecelerateInterpolator());
mCircularReveal.setDuration(500);
mCircularReveal.start();
}
示例2: updateTranslationForSnackbar
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void updateTranslationForSnackbar(CoordinatorLayout parent,
final FooterLayout footerLayout) {
final float targetTransY = getTranslationYForSnackbar(parent, footerLayout);
if (mFooterTranslationY == targetTransY) {
return;
}
final float currentTransY = ViewCompat.getTranslationY(footerLayout);
if (mTranslationYAnimator != null && mTranslationYAnimator.isRunning()) {
mTranslationYAnimator.cancel();
}
if (footerLayout.isShown() && Math.abs(currentTransY - targetTransY) > (footerLayout.getHeight()
* 0.667f)) {
mTranslationYAnimator.setFloatValues(currentTransY, targetTransY);
mTranslationYAnimator.start();
} else {
ViewCompat.setTranslationY(footerLayout, targetTransY);
}
mFooterTranslationY = targetTransY;
}
示例3: endChangeAnimationIfNecessary
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
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;
}
示例4: animateMove
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@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);
int deltaX = toX - fromX;
int deltaY = toY - fromY;
if (deltaX == 0 && deltaY == 0) {
dispatchMoveFinished(holder);
return false;
}
resetAnimation(holder);
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;
}
示例5: endChangeAnimationIfNecessary
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private boolean endChangeAnimationIfNecessary(ChangeInfo changeInfo, RecyclerView.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;
}
示例6: animateChange
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder, int fromX, int fromY,
int toX, int toY) {
final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);
final float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView);
final float prevAlpha = ViewCompat.getAlpha(oldHolder.itemView);
endAnimation(oldHolder);
int deltaX = (int) (toX - fromX - prevTranslationX);
int deltaY = (int) (toY - fromY - prevTranslationY);
// recover prev translation state after ending animation
ViewCompat.setTranslationX(oldHolder.itemView, prevTranslationX);
ViewCompat.setTranslationY(oldHolder.itemView, prevTranslationY);
ViewCompat.setAlpha(oldHolder.itemView, prevAlpha);
if (newHolder != null && newHolder.itemView != null) {
// carry over translation values
endAnimation(newHolder);
ViewCompat.setTranslationX(newHolder.itemView, -deltaX);
ViewCompat.setTranslationY(newHolder.itemView, -deltaY);
ViewCompat.setAlpha(newHolder.itemView, 0);
}
mPendingChanges.add(new ChangeInfo(oldHolder, newHolder, fromX, fromY, toX, toY));
return true;
}
示例7: animateMove
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@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;
}
示例8: run
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void run() {
if (mLayout != null && mOverScroller != null) {
if (mOverScroller.computeScrollOffset()) {
if (BuildConfig.DEBUG) {
Log.d(TAG, "run: " + mOverScroller.getCurrY());
}
ViewCompat.setTranslationY(mLayout, mOverScroller.getCurrY());
ViewCompat.postOnAnimation(mLayout, this);
} else {
onFlingFinished(mParent, mLayout);
}
}
}
示例9: animateAdd
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public boolean animateAdd(final ViewHolder holder) {
resetAnimation(holder);
ViewCompat.setAlpha(holder.itemView, 0);
ViewCompat.setTranslationY(holder.itemView, holder.itemView.getHeight());
mPendingAdditions.add(holder);
return true;
}
示例10: applyAlphaScaleEffect
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void applyAlphaScaleEffect(@NonNull ViewGroup vg, @NonNull TransformParams params, int viewHeight) {
int j = 0;
for (int i = 0, cnt = vg.getChildCount(); i < cnt; i++) {
final View view = vg.getChildAt(i);
ViewCompat.setPivotX(view, params.pivotX);
ViewCompat.setAlpha(view, params.alphaChild);
boolean isHeaderView;
if (params.floorDiff == 1f || view.getTag(R.id.tail_header_tag) == null) {
isHeaderView = view.getY() < viewHeight;
view.setTag(R.id.tail_header_tag, isHeaderView);
} else {
isHeaderView = (Boolean) view.getTag(R.id.tail_header_tag);
}
final float scale = isHeaderView ? params.scale : params.scaleChild;
ViewCompat.setScaleX(view, scale);
ViewCompat.setScaleY(view, scale);
if (isHeaderView) {
ViewCompat.setTranslationY(view, params.offsetY);
} else {
ViewCompat.setTranslationY(view, j * params.offsetY);
j--;
}
}
}
示例11: show
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void show(boolean anim) {
if (getTranslationY() == -getMeasuredHeight()) {
//已经是显示状态
if (anim) {
animate().setDuration(300)
.translationY(0)
.start();
} else {
ViewCompat.setTranslationY(this, 0);
}
}
}
示例12: updateFabTranslationForSnackbar
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void updateFabTranslationForSnackbar(CoordinatorLayout parent,
final FabSpeedDial fab, boolean animationAllowed) {
if (fab.getVisibility() != View.VISIBLE) {
return;
}
final float targetTransY = getFabTranslationYForSnackbar(parent, fab);
if (mFabTranslationY == targetTransY) {
// We're already at (or currently animating to) the target value, return...
return;
}
final float currentTransY = ViewCompat.getTranslationY(fab);
// Make sure that any current animation is cancelled
if (mFabTranslationYAnimator != null) {
mFabTranslationYAnimator.cancel();
}
if (Math.abs(currentTransY - targetTransY) > (fab.getHeight() * 0.667f)) {
mFabTranslationYAnimator = ViewCompat.animate(fab)
.setInterpolator(FabSpeedDial.FAST_OUT_SLOW_IN_INTERPOLATOR)
.translationY(targetTransY);
mFabTranslationYAnimator.start();
} else {
ViewCompat.setTranslationY(fab, targetTransY);
}
mFabTranslationY = targetTransY;
}
示例13: followScrollToolbarLayout
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
* move the toolbarlayout (containing toolbar & tabs)
* following the current scroll
*/
private void followScrollToolbarLayout(float yOffset) {
if (mHeader.toolbar.getBottom() == 0) {
return;
}
if (toolbarJoinsTabs()) {
if (firstScrollValue == Float.MIN_VALUE) {
firstScrollValue = yOffset;
}
float translationY = firstScrollValue - yOffset;
if (translationY > 0) {
translationY = 0;
}
log("translationY " + translationY);
ViewCompat.setTranslationY(mHeader.toolbarLayout, translationY);
} else {
ViewCompat.setTranslationY(mHeader.toolbarLayout, 0);
justToolbarAnimated = false;
}
followScrollToolbarIsVisible = (ViewCompat.getY(mHeader.toolbarLayout) >= 0);
}
示例14: tickleInvalidationFlag
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private static void tickleInvalidationFlag(View view) {
final float y = ViewCompat.getTranslationY(view);
ViewCompat.setTranslationY(view, y + 1);
ViewCompat.setTranslationY(view, y);
}
示例15: preAnimateAddImpl
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
ViewCompat.setTranslationY(holder.itemView, -holder.itemView.getHeight());
ViewCompat.setAlpha(holder.itemView, 0);
}