当前位置: 首页>>代码示例>>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;未经允许,请勿转载。