Example usage for android.view View setTranslationX

List of usage examples for android.view View setTranslationX

Introduction

In this page you can find the example usage for android.view View setTranslationX.

Prototype

public void setTranslationX(float translationX) 

Source Link

Document

Sets the horizontal location of this view relative to its #getLeft() left position.

Usage

From source file:Main.java

public static void undoSlideLeftRight(View view) {
    view.setTranslationX(0f);
}

From source file:me.lizheng.deckview.helpers.DeckChildViewTransform.java

/**
 * Reset the transform on a view./* ww  w.j a  v a2  s.c  o m*/
 */
public static void reset(View v) {
    v.setTranslationX(0f);
    v.setTranslationY(0f);
    ViewCompat.setTranslationZ(v, 0f);
    v.setScaleX(1f);
    v.setScaleY(1f);
    v.setAlpha(1f);
}

From source file:Main.java

public static void rotateView(@NonNull View rotatedView) {
    int w = rotatedView.getWidth(), h = rotatedView.getHeight();
    int diff = w / 2 - h / 2;
    rotatedView.setRotation(270);//ww w  .  ja v a  2 s .  co m
    rotatedView.setTranslationX(-diff);
}

From source file:Main.java

private static void translateViewForParallaxEffect(View view, int index, int offsetPixels,
        float startParallaxFactor, float parallaxInterval) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        view.setTranslationX(
                calculateParallaxOffsetAmount(index, offsetPixels, startParallaxFactor, parallaxInterval));
    }//w ww  . j  av  a2 s .com
}

From source file:com.facebook.react.uimanager.BaseViewManager.java

private static void resetTransformProperty(View view) {
    view.setTranslationX(PixelUtil.toPixelFromDIP(0));
    view.setTranslationY(PixelUtil.toPixelFromDIP(0));
    view.setRotation(0);//  ww  w . j a  v  a2  s.  com
    view.setRotationX(0);
    view.setRotationY(0);
    view.setScaleX(1);
    view.setScaleY(1);
    view.setCameraDistance(0);
}

From source file:com.kogitune.activitytransition.core.TransitionAnimation.java

private static void runEnterAnimation(MoveData moveData, TimeInterpolator interpolator) {
    final View toView = moveData.toView;
    toView.setPivotX(0);//from w w w.  java  2  s .  com
    toView.setPivotY(0);
    toView.setScaleX(moveData.widthScale);
    toView.setScaleY(moveData.heightScale);
    toView.setTranslationX(moveData.leftDelta);
    toView.setTranslationY(moveData.topDelta);

    toView.animate().setDuration(moveData.duration).scaleX(1).scaleY(1).translationX(0).translationY(0)
            .setInterpolator(interpolator);
}

From source file:com.facebook.react.uimanager.BaseViewManager.java

private static void setTransformProperty(View view, ReadableArray transforms) {
    TransformHelper.processTransform(transforms, sTransformDecompositionArray);
    MatrixMathHelper.decomposeMatrix(sTransformDecompositionArray, sMatrixDecompositionContext);
    view.setTranslationX(PixelUtil.toPixelFromDIP((float) sMatrixDecompositionContext.translation[0]));
    view.setTranslationY(PixelUtil.toPixelFromDIP((float) sMatrixDecompositionContext.translation[1]));
    view.setRotation((float) sMatrixDecompositionContext.rotationDegrees[2]);
    view.setRotationX((float) sMatrixDecompositionContext.rotationDegrees[0]);
    view.setRotationY((float) sMatrixDecompositionContext.rotationDegrees[1]);
    view.setScaleX((float) sMatrixDecompositionContext.scale[0]);
    view.setScaleY((float) sMatrixDecompositionContext.scale[1]);

    double[] perspectiveArray = sMatrixDecompositionContext.perspective;

    if (perspectiveArray.length > PERSPECTIVE_ARRAY_INVERTED_CAMERA_DISTANCE_INDEX) {
        float invertedCameraDistance = (float) perspectiveArray[PERSPECTIVE_ARRAY_INVERTED_CAMERA_DISTANCE_INDEX];
        if (invertedCameraDistance == 0) {
            // Default camera distance, before scale multiplier (1280)
            invertedCameraDistance = 0.00078125f;
        }/*from  w  w  w.  ja  v  a2 s .c  o m*/
        float cameraDistance = -1 / invertedCameraDistance;
        float scale = DisplayMetricsHolder.getScreenDisplayMetrics().density;

        // The following converts the matrix's perspective to a camera distance
        // such that the camera perspective looks the same on Android and iOS.
        // The native Android implementation removed the screen density from the
        // calculation, so squaring and a normalization value of
        // sqrt(5) produces an exact replica with iOS.
        // For more information, see https://github.com/facebook/react-native/pull/18302
        float normalizedCameraDistance = scale * scale * cameraDistance
                * CAMERA_DISTANCE_NORMALIZATION_MULTIPLIER;
        view.setCameraDistance(normalizedCameraDistance);

    }
}

From source file:android.support.transition.ChangeTransform.java

private static void setTransforms(View view, float translationX, float translationY, float translationZ,
        float scaleX, float scaleY, float rotationX, float rotationY, float rotationZ) {
    view.setTranslationX(translationX);
    view.setTranslationY(translationY);/*  w  ww.  j  a  v a  2s . c  o m*/
    ViewCompat.setTranslationZ(view, translationZ);
    view.setScaleX(scaleX);
    view.setScaleY(scaleY);
    view.setRotationX(rotationX);
    view.setRotationY(rotationY);
    view.setRotation(rotationZ);
}

From source file:com.android.wneng.widget.vertcalViewPager.transforms.StackTransformer.java

@Override
public void transformPage(View page, float position) {
    page.setTranslationX(page.getWidth() * -position);
    page.setTranslationY(position < 0 ? position * page.getHeight() : 0f);
}

From source file:com.qs.qswlw.view.Mypager.transformer.UltraVerticalTransformer.java

@Override
public void transformPage(View view, float position) {
    view.setTranslationX(view.getWidth() * -position);
    yPosition = position * view.getHeight();
    view.setTranslationY(yPosition);//  w  ww.j a v a2 s  . co m
}