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


Java ViewCompat.setTranslationX方法代码示例

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


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

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

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

示例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:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:FlexibleItemAnimator.java

示例4: 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:qsyj,项目名称:ShortcutMenu,代码行数:17,代码来源:ShortMenuAnimator.java

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

示例6: handleRightPage

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void handleRightPage(View view, float position) {
    ViewCompat.setTranslationX(view, -view.getWidth() * position);

    ViewCompat.setPivotX(view, view.getWidth() * 0.5f);
    ViewCompat.setPivotY(view, view.getHeight() * 0.5f);
    ViewCompat.setScaleX(view, 1 + position);
    ViewCompat.setScaleY(view, 1 + position);

    if (position > 0.95f) {
        ViewCompat.setAlpha(view, 0);
    } else {
        ViewCompat.setAlpha(view, 1);
    }
}
 
开发者ID:devzwy,项目名称:KUtils,代码行数:16,代码来源:ZoomStackPageTransformer.java

示例7: handleRightPage

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void handleRightPage(View view, float position) {
    ViewCompat.setTranslationX(view, -view.getWidth() * position);

    ViewCompat.setPivotX(view, view.getWidth() * 0.5f);
    ViewCompat.setPivotY(view, view.getHeight() * 0.5f);
    ViewCompat.setScaleX(view, 1 - position);
    ViewCompat.setScaleY(view, 1 - position);

    if (position > 0.95f) {
        ViewCompat.setAlpha(view, 0);
    } else {
        ViewCompat.setAlpha(view, 1);
    }
}
 
开发者ID:devzwy,项目名称:NeiHanDuanZiTV,代码行数:16,代码来源:ZoomCenterPageTransformer.java

示例8: handleLeftPage

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void handleLeftPage(View view, float position) {
    float scale = Math.max(mMinScale, 1 + position);
    float vertMargin = view.getHeight() * (1 - scale) / 2;
    float horzMargin = view.getWidth() * (1 - scale) / 2;
    ViewCompat.setTranslationX(view, horzMargin - vertMargin / 2);
    ViewCompat.setScaleX(view, scale);
    ViewCompat.setScaleY(view, scale);
    ViewCompat.setAlpha(view, mMinAlpha + (scale - mMinScale) / (1 - mMinScale) * (1 - mMinAlpha));
}
 
开发者ID:liu-xiao-dong,项目名称:JD-Test,代码行数:11,代码来源:ZoomPageTransformer.java

示例9: handleLeftPage

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void handleLeftPage(View view, float position) {
    ViewCompat.setTranslationX(view, -view.getWidth() * position);

    ViewCompat.setPivotX(view, view.getWidth() * 0.5f);
    ViewCompat.setPivotY(view, view.getHeight() * 0.5f);
    ViewCompat.setScaleX(view, 1 + position);
    ViewCompat.setScaleY(view, 1 + position);

    if (position < -0.95f) {
        ViewCompat.setAlpha(view, 0);
    } else {
        ViewCompat.setAlpha(view, 1);
    }
}
 
开发者ID:devzwy,项目名称:NeiHanDuanZiTV,代码行数:16,代码来源:ZoomCenterPageTransformer.java

示例10: onPanelDragged

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
void onPanelDragged(int newLeft) {
     if (mSlideableView == null) {
         // This can happen if we're aborting motion during layout because everything now fits.
         mSlideOffset = 0;
   //      Log.v("dispatchKeyEvent", " 1121, mSlideOffset = " + mSlideOffset);
         return;
     }
     final boolean isLayoutRtl = isLayoutRtlSupport();
     final LayoutParams lp = (LayoutParams) mSlideableView.getLayoutParams();

     int childWidth = mSlideableView.getWidth();
     final int newStart = isLayoutRtl ? getWidth() - newLeft - childWidth : newLeft;

     final int paddingStart = isLayoutRtl ? getPaddingRight() : getPaddingLeft();
     final int lpMargin = isLayoutRtl ? lp.rightMargin : lp.leftMargin;
     final int startBound = paddingStart + lpMargin;

     mSlideOffset = (float) (newStart - startBound) / mSlideRange;
//    Log.v("dispatchKeyEvent", " 1135, mSlideOffset = " + mSlideOffset);

     if (mParallaxBy != 0) {
         parallaxOtherViews(mSlideOffset);
     }

     if (lp.dimWhenOffset) {
         dimChildView(mSlideableView, mSlideOffset, mSliderFadeColor);
     }

     // ======================== 新加的 START ========================
     ViewCompat.setTranslationX(mShadowView, -mShadowView.getMeasuredWidth() + newLeft);
     // ======================== 新加的 END ========================

     dispatchOnPanelSlide(mSlideableView);
 }
 
开发者ID:zhudongya123,项目名称:WechatChatroomHelper,代码行数:35,代码来源:BGASwipeBackLayout2.java

示例11: handleLeftPage

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void handleLeftPage(View view, float position) {
    ViewCompat.setTranslationX(view, -view.getWidth() * position);
    float rotation = (ROTATION * position);
    ViewCompat.setRotationY(view, rotation);

    if (position > -0.5) {
        view.setVisibility(View.VISIBLE);
    } else {
        view.setVisibility(View.INVISIBLE);
    }
}
 
开发者ID:liu-xiao-dong,项目名称:JD-Test,代码行数:13,代码来源:FlipPageTransformer.java

示例12: handleLeftPage

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void handleLeftPage(View view, float position) {
    ViewCompat.setTranslationX(view, -view.getWidth() * position);
    ViewCompat.setAlpha(view, 1 + position);
}
 
开发者ID:weileng11,项目名称:KUtils-master,代码行数:6,代码来源:FadePageTransformer.java

示例13: preAnimateAddImpl

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
    ViewCompat.setTranslationX(holder.itemView, -holder.itemView.getRootView().getWidth() * .25f);
    ViewCompat.setAlpha(holder.itemView, 0);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:6,代码来源:FadeInLeftAnimator.java

示例14: onDraw

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@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);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:7,代码来源:ItemTouchUIUtilImpl.java

示例15: preAnimateAddImpl

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
    ViewCompat.setTranslationX(holder.itemView, -holder.itemView.getRootView().getWidth());
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:5,代码来源:SlideInLeftAnimator.java


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