當前位置: 首頁>>代碼示例>>Java>>正文


Java View.setTranslationX方法代碼示例

本文整理匯總了Java中android.view.View.setTranslationX方法的典型用法代碼示例。如果您正苦於以下問題:Java View.setTranslationX方法的具體用法?Java View.setTranslationX怎麽用?Java View.setTranslationX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.View的用法示例。


在下文中一共展示了View.setTranslationX方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createShowItemAnimator

import android.view.View; //導入方法依賴的package包/類
private Animator createShowItemAnimator(View item) {

        float dx = fab.getX() - item.getX();
        float dy = fab.getY() - item.getY();

        item.setRotation(0f);
        item.setTranslationX(dx);
        item.setTranslationY(dy);

        Animator anim = ObjectAnimator.ofPropertyValuesHolder(
                item,
//                AnimatorUtils.rotation(0f, 720f),
                AnimatorUtils.translationX(dx, 0f),
                AnimatorUtils.translationY(dy, 0f)
        );

        return anim;
    }
 
開發者ID:xzg8023,項目名稱:ArcLayout-master,代碼行數:19,代碼來源:MainActivity.java

示例2: transformPage

import android.view.View; //導入方法依賴的package包/類
public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();

    if (position < -1) { // [-Infinity,-1)
        view.setAlpha(0);
    } else if (position <= 0) { // [-1,0]
        view.setAlpha(1);
        view.setTranslationX(0);
        view.setScaleX(1);
        view.setScaleY(1);
    } else if (position <= 1) { // (0,1]
        view.setAlpha(1 - position);
        view.setTranslationX(pageWidth * -position);
        float scaleFactor = MIN_SCALE
                + (1 - MIN_SCALE) * (1 - Math.abs(position));
        view.setScaleX(scaleFactor);
        view.setScaleY(scaleFactor);

    } else { // (1,+Infinity]
        view.setAlpha(0);
    }
}
 
開發者ID:shucc,項目名稱:Carousel,代碼行數:23,代碼來源:DepthPageTransformer.java

示例3: onPreTransform

import android.view.View; //導入方法依賴的package包/類
/**
	 * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)}.
	 * <p>
	 * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
	 * not modify the same page properties. For instance changing from a transformation that applies rotation to a
	 * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
	 * alpha.
	 *
	 * @param page
	 *            Apply the transformation to this page
	 * @param position
	 *            Position of page relative to the current front-and-center position of the pager. 0 is front and
	 *            center. 1 is one full page position to the right, and -1 is one page position to the left.
	 */
	protected void onPreTransform(View page, float position) {
		final float width = page.getWidth();

		page.setRotationX(0);
		page.setRotationY(0);
		page.setRotation(0);
		page.setScaleX(1);
		page.setScaleY(1);
		page.setPivotX(0);
		page.setPivotY(0);
		page.setTranslationY(0);
		page.setTranslationX(isPagingEnabled() ? 0f : -width * position);

		if (hideOffscreenPages()) {
			page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
//			page.setEnabled(false);
		} else {
//			page.setEnabled(true);
			page.setAlpha(1f);
		}
	}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:36,代碼來源:ABaseTransformer.java

示例4: onTransform

import android.view.View; //導入方法依賴的package包/類
protected void onTransform(View view, float position) {
    float scale = 1.0f + Math.abs(position);
    view.setScaleX(scale);
    view.setScaleY(scale);
    view.setPivotX(((float) view.getWidth()) * 0.5f);
    view.setPivotY(((float) view.getHeight()) * 0.5f);
    float f = (position < -1.0f || position > 1.0f) ? 0.0f : 1.0f - (scale - 1.0f);
    view.setAlpha(f);
    if (position == -1.0f) {
        view.setTranslationX((float) (view.getWidth() * -1));
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:13,代碼來源:ZoomOutTranformer.java

示例5: onPreTransform

import android.view.View; //導入方法依賴的package包/類
/**
 * Called each {@link #transformPage(android.view.View, float)} before {{@link #onTransform(android.view.View, float)}.
 * <p>
 * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do
 * not modify the same page properties. For instance changing from a transformation that applies rotation to a
 * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied
 * alpha.
 * 
 * @param page
 *            Apply the transformation to this page
 * @param position
 *            Position of page relative to the current front-and-center position of the pager. 0 is front and
 *            center. 1 is one full page position to the right, and -1 is one page position to the left.
 */
protected void onPreTransform(View page, float position) {
	final float width = page.getWidth();

	page.setRotationX(0);
	page.setRotationY(0);
	page.setRotation(0);
	page.setScaleX(1);
	page.setScaleY(1);
	page.setPivotX(0);
	page.setPivotY(0);
	page.setTranslationY(0);
	page.setTranslationX(isPagingEnabled() ? 0f : -width * position);

	if (hideOffscreenPages()) {
		page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
	} else {
		page.setAlpha(1f);
	}
}
 
開發者ID:AndroidBoySC,項目名稱:Mybilibili,代碼行數:34,代碼來源:ABaseTransformer.java

示例6: onTransform

import android.view.View; //導入方法依賴的package包/類
@Override
protected void onTransform(View view, float position) {
	final float rotation = (position < 0 ? 30f : -30f) * Math.abs(position);

	view.setTranslationX(getOffsetXForRotation(rotation, view.getWidth(), view.getHeight()));
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(0);
	view.setRotationY(rotation);
}
 
開發者ID:OCNYang,項目名稱:PageTransformerHelp,代碼行數:10,代碼來源:TabletTransformer.java

示例7: showPromoView

import android.view.View; //導入方法依賴的package包/類
/**
 * Shows the Promo Android View. By making the Android View visible, we are allowing the
 * Promo to be interactive. Since snapshots are not interactive (they are just a bitmap),
 * we need to temporarily show the Android View on top of the snapshot, so the user will
 * be able to click in the Promo buttons and/or link.
 */
private void showPromoView() {
    float y = getYPx();
    View view = getView();
    if (view == null
            || !mIsVisible
            || (mIsShowingView && mPromoViewY == y)
            || mHeightPx == 0.f) return;

    float offsetX = mOverlayPanel.getOffsetX() * mDpToPx;
    if (LocalizationUtils.isLayoutRtl()) {
        offsetX = -offsetX;
    }

    view.setTranslationX(offsetX);
    view.setTranslationY(y);
    view.setVisibility(View.VISIBLE);

    // NOTE(pedrosimonetti): We need to call requestLayout, otherwise
    // the Promo View will not become visible.
    view.requestLayout();

    mIsShowingView = true;
    mPromoViewY = y;

    // The Promo can only be interacted when the View is being displayed.
    mWasInteractive = true;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:34,代碼來源:ContextualSearchPromoControl.java

示例8: onTransform

import android.view.View; //導入方法依賴的package包/類
protected void onTransform(View view, float position) {
    float rotation = (position < 0.0f ? 30.0f : -30.0f) * Math.abs(position);
    view.setTranslationX(getOffsetXForRotation(rotation, view.getWidth(), view.getHeight()));
    view.setPivotX(((float) view.getWidth()) * 0.5f);
    view.setPivotY(0.0f);
    view.setRotationY(rotation);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:8,代碼來源:TabletTransformer.java

示例9: resetTransformProperty

import android.view.View; //導入方法依賴的package包/類
private static void resetTransformProperty(View view) {
  view.setTranslationX(PixelUtil.toPixelFromDIP(0));
  view.setTranslationY(PixelUtil.toPixelFromDIP(0));
  view.setRotation(0);
  view.setRotationX(0);
  view.setRotationY(0);
  view.setScaleX(1);
  view.setScaleY(1);
  view.setCameraDistance(0);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:11,代碼來源:BaseViewManager.java

示例10: onTransform

import android.view.View; //導入方法依賴的package包/類
@Override
protected void onTransform(View view, float position) {
    final float scale = 1f + Math.abs(position);
    view.setScaleX(scale);
    view.setScaleY(scale);
    view.setPivotX(view.getWidth() * 0.5f);
    view.setPivotY(view.getHeight() * 0.5f);
    view.setAlpha(position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
    if (position == -1) {
        view.setTranslationX(view.getWidth() * -1);
    }
}
 
開發者ID:ahmet12,項目名稱:easlider,代碼行數:13,代碼來源:ZoomOutTransformer.java

示例11: transformPage

import android.view.View; //導入方法依賴的package包/類
public void transformPage(@NonNull View view, float position) {
    int pageWidth = view.getWidth();
    int pageHeight = view.getHeight();

    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
        view.setAlpha(0);

    } else if (position <= 1) { // [-1,1]
        // Modify the default slide transition to shrink the page as well
        float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
        float vertMargin = pageHeight * (1 - scaleFactor) / 2;
        float horzMargin = pageWidth * (1 - scaleFactor) / 2;
        if (position < 0) {
            view.setTranslationX(horzMargin - vertMargin / 2);
        } else {
            view.setTranslationX(-horzMargin + vertMargin / 2);
        }

        // Scale the page down (between MIN_SCALE and 1)
        view.setScaleX(scaleFactor);
        view.setScaleY(scaleFactor);

        // Fade the page relative to its size.
        view.setAlpha(MIN_ALPHA +
                (scaleFactor - MIN_SCALE) /
                        (1 - MIN_SCALE) * (1 - MIN_ALPHA));

    } else { // (1,+Infinity]
        // This page is way off-screen to the right.
        view.setAlpha(0);
    }
}
 
開發者ID:enricocid,項目名稱:ColorBox-library,代碼行數:34,代碼來源:ZoomOutPageTransformer.java

示例12: onTransform

import android.view.View; //導入方法依賴的package包/類
@Override
protected void onTransform(View view, float position) {
	if (position >= -1 || position <= 1) {
		// Modify the default slide transition to shrink the page as well
		final float height = view.getHeight();
		final float width = view.getWidth();
		final float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
		final float vertMargin = height * (1 - scaleFactor) / 2;
		final float horzMargin = width * (1 - scaleFactor) / 2;

		// Center vertically
		view.setPivotY(0.5f * height);
		view.setPivotX(0.5f * width);

		if (position < 0) {
			view.setTranslationX(horzMargin - vertMargin / 2);
		} else {
			view.setTranslationX(-horzMargin + vertMargin / 2);
		}

		// Scale the page down (between MIN_SCALE and 1)
		view.setScaleX(scaleFactor);
		view.setScaleY(scaleFactor);

		// Fade the page relative to its size.
		view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));
	}
}
 
開發者ID:Mrqinlei,項目名稱:ImitateZHRB,代碼行數:29,代碼來源:ZoomOutSlideTransformer.java

示例13: transformPageDepth

import android.view.View; //導入方法依賴的package包/類
private void transformPageDepth(View view, float position) {
    final float MIN_SCALE = 0.75f;

    int pageWidth = view.getWidth();

    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
        view.setAlpha(0);
    } else if (position <= 0) { // [-1,0]
        // Use the default slide transition when moving to the left page
        view.setAlpha(1);
        view.setTranslationX(0);
        view.setScaleX(1);
        view.setScaleY(1);
    } else if (position <= 1) { // (0,1]
        // Fade the page out.
        view.setAlpha(1 - position);

        // Counteract the default slide transition
        view.setTranslationX(pageWidth * -position);

        // Scale the page down (between MIN_SCALE and 1)
        float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
        view.setScaleX(scaleFactor);
        view.setScaleY(scaleFactor);
    } else { // (1,+Infinity]
        // This page is way off-screen to the right.
        view.setAlpha(0);
    }
}
 
開發者ID:homeii,項目名稱:GxIconAndroid,代碼行數:31,代碼來源:SimplePageTransformer.java

示例14: transformPage

import android.view.View; //導入方法依賴的package包/類
@Override
public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();
    int pageHeight = view.getHeight();
    float alpha = 0;
    if (0 <= position && position <= 1) {
        alpha = 1 - position;
    } else if (-1 < position && position < 0) {
        float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
        float verticalMargin = pageHeight * (1 - scaleFactor) / 2;
        float horizontalMargin = pageWidth * (1 - scaleFactor) / 2;
        if (position < 0) {
            view.setTranslationX(horizontalMargin - verticalMargin / 2);
        } else {
            view.setTranslationX(-horizontalMargin + verticalMargin / 2);
        }

        view.setScaleX(scaleFactor);
        view.setScaleY(scaleFactor);

        alpha = position + 1;
    }

    view.setAlpha(alpha);
    view.setTranslationX(view.getWidth() * -position);
    float yPosition = position * view.getHeight();
    view.setTranslationY(yPosition);
}
 
開發者ID:chadguo,項目名稱:VerticalViewPager,代碼行數:29,代碼來源:ZoomOutTransformer.java

示例15: setTranslation

import android.view.View; //導入方法依賴的package包/類
/**
 * 設置Translation X, Y
 *
 * @param tx
 * @param ty
 * @return
 */
public UDView setTranslation(Float tx, Float ty) {
    final View view = getView();
    if (view != null) {
        if (tx != null) {
            view.setTranslationX(tx);
        }
        if (ty != null) {
            view.setTranslationY(ty);
        }
    }
    return this;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:20,代碼來源:UDView.java


注:本文中的android.view.View.setTranslationX方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。