当前位置: 首页>>代码示例>>Java>>正文


Java ViewCompat.setTranslationY方法代码示例

本文整理汇总了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();
}
 
开发者ID:teisun,项目名称:SunmiUI,代码行数:17,代码来源:ImageSharedTransitionActivity.java

示例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;
}
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:25,代码来源:FooterBehavior.java

示例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;
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:17,代码来源:BaseItemAnimator.java

示例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;
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:23,代码来源:VerticalItemAnimator.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:BaseItemAnimator.java

示例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;
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:24,代码来源:BaseItemAnimator.java

示例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;
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:22,代码来源:BaseItemAnimator.java

示例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);
        }
    }
}
 
开发者ID:Learzhu,项目名称:UcMainPagerDemo-master,代码行数:15,代码来源:UcNewsHeaderPagerBehavior.java

示例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;
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:9,代码来源:HorizontalItemAnimator.java

示例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--;
        }
    }
}
 
开发者ID:Ramotion,项目名称:garland-view-android,代码行数:29,代码来源:TailItemTransformer.java

示例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);
        }
    }
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:13,代码来源:UITitleBarContainer.java

示例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;
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:32,代码来源:FabSpeedDialBehaviour.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:MaterialViewPagerAnimator.java

示例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);
}
 
开发者ID:Learzhu,项目名称:UcMainPagerDemo-master,代码行数:6,代码来源:ViewOffsetHelper.java

示例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);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:6,代码来源:SlideInDownAnimator.java


注:本文中的android.support.v4.view.ViewCompat.setTranslationY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。