當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。