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


Java ViewCompat.getTranslationX方法代码示例

本文整理汇总了Java中android.support.v4.view.ViewCompat.getTranslationX方法的典型用法代码示例。如果您正苦于以下问题:Java ViewCompat.getTranslationX方法的具体用法?Java ViewCompat.getTranslationX怎么用?Java ViewCompat.getTranslationX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.view.ViewCompat的用法示例。


在下文中一共展示了ViewCompat.getTranslationX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: animateMove

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public boolean animateMove(final RecyclerView.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);
    resetAnimation(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:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:BaseItemAnimator.java

示例3: findChildViewUnder

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public View findChildViewUnder(float x, float y) {
    for (int i = this.mChildHelper.getChildCount() - 1; i >= 0; i--) {
        View child = this.mChildHelper.getChildAt(i);
        float translationX = ViewCompat.getTranslationX(child);
        float translationY = ViewCompat.getTranslationY(child);
        if (x >= ((float) child.getLeft()) + translationX && x <= ((float) child.getRight()) + translationX && y >= ((float) child.getTop()) + translationY && y <= ((float) child.getBottom()) + translationY) {
            return child;
        }
    }
    return null;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:12,代码来源:RecyclerView.java

示例4: animateChange

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder, int fromX, int fromY, int toX, int toY) {
    if (oldHolder == newHolder) {
        return animateMove(oldHolder, fromX, fromY, toX, toY);
    }
    float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);
    float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView);
    float prevAlpha = ViewCompat.getAlpha(oldHolder.itemView);
    resetAnimation(oldHolder);
    int deltaX = (int) (((float) (toX - fromX)) - prevTranslationX);
    int deltaY = (int) (((float) (toY - fromY)) - prevTranslationY);
    ViewCompat.setTranslationX(oldHolder.itemView, prevTranslationX);
    ViewCompat.setTranslationY(oldHolder.itemView, prevTranslationY);
    ViewCompat.setAlpha(oldHolder.itemView, prevAlpha);
    if (newHolder != null) {
        resetAnimation(newHolder);
        ViewCompat.setTranslationX(newHolder.itemView, (float) (-deltaX));
        ViewCompat.setTranslationY(newHolder.itemView, (float) (-deltaY));
        ViewCompat.setAlpha(newHolder.itemView, 0.0f);
    }
    this.mPendingChanges.add(new ChangeInfo(oldHolder, newHolder, fromX, fromY, toX, toY));
    return true;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:23,代码来源:DefaultItemAnimator.java

示例5: 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:angcyo,项目名称:RLibrary,代码行数:24,代码来源:BaseItemAnimator.java

示例6: 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:angcyo,项目名称:RLibrary,代码行数:22,代码来源:BaseItemAnimator.java

示例7: getDividerBound

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
protected Rect getDividerBound(int position, RecyclerView parent, View child) {
    Rect bounds = new Rect(0, 0, 0, 0);
    int transitionX = (int) ViewCompat.getTranslationX(child);
    int transitionY = (int) ViewCompat.getTranslationY(child);
    RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
    bounds.left = parent.getPaddingLeft() +
            mMarginProvider.dividerLeftMargin(position, parent) + transitionX;
    bounds.right = parent.getWidth() - parent.getPaddingRight() -
            mMarginProvider.dividerRightMargin(position, parent) + transitionX;

    int dividerSize = getDividerSize(position, parent);
    if (mDividerType == DividerType.DRAWABLE) {
        bounds.top = child.getBottom() + params.topMargin + transitionY;
        bounds.bottom = bounds.top + dividerSize;
    } else {
        bounds.top = child.getBottom() + params.topMargin + dividerSize / 2 + transitionY;
        bounds.bottom = bounds.top;
    }

    return bounds;
}
 
开发者ID:Jusenr,项目名称:AppFirCloud,代码行数:23,代码来源:HorizontalDividerItemDecoration.java

示例8: animateMove

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public boolean animateMove(ViewHolder holder, int fromX, int fromY, int toX, int toY) {
    View view = holder.itemView;
    fromX = (int) (((float) fromX) + ViewCompat.getTranslationX(holder.itemView));
    fromY = (int) (((float) fromY) + ViewCompat.getTranslationY(holder.itemView));
    resetAnimation(holder);
    int deltaX = toX - fromX;
    int deltaY = toY - fromY;
    if (deltaX == 0 && deltaY == 0) {
        dispatchMoveFinished(holder);
        return false;
    }
    if (deltaX != 0) {
        ViewCompat.setTranslationX(view, (float) (-deltaX));
    }
    if (deltaY != 0) {
        ViewCompat.setTranslationY(view, (float) (-deltaY));
    }
    this.mPendingMoves.add(new MoveInfo(holder, fromX, fromY, toX, toY));
    return true;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:21,代码来源:DefaultItemAnimator.java

示例9: animateChange

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public boolean animateChange(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder,
                             int fromX, int fromY, int toX, int toY) {
    if (oldHolder == newHolder) {
        // Don't know how to run change animations when the same view holder is re-used.
        // run a move animation to handle position changes.
        return animateMove(oldHolder, fromX, fromY, toX, toY);
    }
    final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);
    final float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView);
    final float prevAlpha = ViewCompat.getAlpha(oldHolder.itemView);
    resetAnimation(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) {
        // carry over translation values
        resetAnimation(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:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:BaseItemAnimator.java

示例10: animateChange

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder,
							 int fromX, int fromY, int toX, int toY) {
	if (oldHolder == newHolder) {
		// Don't know how to run change animations when the same view holder is re-used.
		// run a move animation to handle position changes.
		return animateMove(oldHolder, fromX, fromY, toX, toY);
	}
	final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);
	final float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView);
	final float prevAlpha = ViewCompat.getAlpha(oldHolder.itemView);
	resetAnimation(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) {
		// Carry over translation values
		resetAnimation(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:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:FlexibleItemAnimator.java

示例11: update

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void update() {
    if (this.mStartDx == this.mTargetX) {
        this.mX = ViewCompat.getTranslationX(this.mViewHolder.itemView);
    } else {
        this.mX = this.mStartDx + (this.mFraction * (this.mTargetX - this.mStartDx));
    }
    if (this.mStartDy == this.mTargetY) {
        this.mY = ViewCompat.getTranslationY(this.mViewHolder.itemView);
    } else {
        this.mY = this.mStartDy + (this.mFraction * (this.mTargetY - this.mStartDy));
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:13,代码来源:ItemTouchHelper.java

示例12: update

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
 * We run updates on onDraw method but use the fraction from animator callback.
 * This way, we can sync translate x/y values w/ the animators to avoid one-off frames.
 */
public void update() {
    if (mStartDx == mTargetX) {
        mX = ViewCompat.getTranslationX(mViewHolder.itemView);
    } else {
        mX = mStartDx + mFraction * (mTargetX - mStartDx);
    }
    if (mStartDy == mTargetY) {
        mY = ViewCompat.getTranslationY(mViewHolder.itemView);
    } else {
        mY = mStartDy + mFraction * (mTargetY - mStartDy);
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:17,代码来源:ItemTouchHelper.java

示例13: animateChange

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder,
        int fromX, int fromY, int toX, int toY) {
    if (oldHolder == newHolder) {
        // Don't know how to run change animations when the same view holder is re-used.
        // run a move animation to handle position changes.
        return animateMove(oldHolder, fromX, fromY, toX, toY);
    }
    final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);
    final float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView);
    final float prevAlpha = ViewCompat.getAlpha(oldHolder.itemView);
    resetAnimation(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) {
        // carry over translation values
        resetAnimation(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:MLNO,项目名称:airgram,代码行数:29,代码来源:DefaultItemAnimator.java

示例14: animateAdd

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public boolean animateAdd(final RecyclerView.ViewHolder holder) {
    if (adapter == null) {
        adapter = (ChannelAdapter) rv.getAdapter();
    }
    int adapterPosition=holder.getAdapterPosition();
    int type=adapter.getItemViewType(adapterPosition);
    int position=0;
    ShortcutMenuBean shortcutMenuBean;
    switch (type) {
        case ChannelAdapter.TYPE_MY:
        case ChannelAdapter.TYPE_OTHER:
            if (type == ChannelAdapter.TYPE_MY) {
                position = adapterPosition - ChannelAdapter.getCountPreMyHeader();
                shortcutMenuBean = adapter.getMyChannelItems().get(position);
            } else {
                position = adapterPosition - ChannelAdapter.getCountPreOtherHeader() - adapter.getMyChannelItems().size();
                shortcutMenuBean = adapter.getOtherChannelItems().get(position);
            }
            if (shortcutMenuBean.isMove()) {
                View view=holder.itemView;
                if (type == ChannelAdapter.TYPE_MY) {
                    view.bringToFront();
                }
                int toX=view.getLeft();
                int toY=holder.itemView.getTop();
                ShortcutMenuBean.MoveInfo moveInfo=shortcutMenuBean.getMoveInfo();
                int fromX=moveInfo.getFromX();
                int fromY = moveInfo.getFromY();
                fromX += ViewCompat.getTranslationX(holder.itemView);
                fromY += ViewCompat.getTranslationY(holder.itemView);
                resetAnimation(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));
                shortcutMenuBean.setMoveInfo(null);
                return true;
            }
            break;
    }
    resetAnimation(holder);
    ViewCompat.setAlpha(holder.itemView, 0);
    mPendingAdditions.add(holder);
    return true;
}
 
开发者ID:qsyj,项目名称:ShortcutMenu,代码行数:56,代码来源:ShortMenuAnimator.java

示例15: getSelectedDxDy

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void getSelectedDxDy(float[] outPosition) {
    if ((mSelectedFlags & (LEFT | RIGHT)) != 0) {
        outPosition[0] = mSelectedStartX + mDx - mSelected.itemView.getLeft();
    } else {
        outPosition[0] = ViewCompat.getTranslationX(mSelected.itemView);
    }
    if ((mSelectedFlags & (UP | DOWN)) != 0) {
        outPosition[1] = mSelectedStartY + mDy - mSelected.itemView.getTop();
    } else {
        outPosition[1] = ViewCompat.getTranslationY(mSelected.itemView);
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:13,代码来源:ItemTouchHelper.java


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