Example usage for android.view ViewGroup getTranslationY

List of usage examples for android.view ViewGroup getTranslationY

Introduction

In this page you can find the example usage for android.view ViewGroup getTranslationY.

Prototype

@ViewDebug.ExportedProperty(category = "drawing")
public float getTranslationY() 

Source Link

Document

The vertical location of this view relative to its #getTop() top position.

Usage

From source file:io.digibyte.tools.animation.BRAnimator.java

public static void animateSignalSlide(ViewGroup signalLayout, final boolean reverse,
        final OnSlideAnimationEnd listener) {
    float translationY = signalLayout.getTranslationY();
    float signalHeight = signalLayout.getHeight();
    signalLayout.setTranslationY(reverse ? translationY : translationY + signalHeight);

    signalLayout.animate().translationY(reverse ? BreadActivity.screenParametersPoint.y : translationY)
            .setDuration(SLIDE_ANIMATION_DURATION)
            .setInterpolator(reverse ? new DecelerateInterpolator() : new OvershootInterpolator(0.7f))
            .setListener(new AnimatorListenerAdapter() {
                @Override//from  ww  w.  j  av a  2s . c o m
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    if (listener != null)
                        listener.onAnimationEnd();
                }
            });

}

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

@Override
public long getStartDelay(ViewGroup sceneRoot, Transition transition, TransitionValues startValues,
        TransitionValues endValues) {//from   w  ww  .  j  a v a  2s.  com
    if (startValues == null && endValues == null) {
        return 0;
    }
    int directionMultiplier = 1;
    Rect epicenter = transition.getEpicenter();
    TransitionValues positionValues;
    if (endValues == null || getViewVisibility(startValues) == View.VISIBLE) {
        positionValues = startValues;
        directionMultiplier = -1;
    } else {
        positionValues = endValues;
    }

    int viewCenterX = getViewX(positionValues);
    int viewCenterY = getViewY(positionValues);

    int[] loc = new int[2];
    sceneRoot.getLocationOnScreen(loc);
    int left = loc[0] + Math.round(sceneRoot.getTranslationX());
    int top = loc[1] + Math.round(sceneRoot.getTranslationY());
    int right = left + sceneRoot.getWidth();
    int bottom = top + sceneRoot.getHeight();

    int epicenterX;
    int epicenterY;
    if (epicenter != null) {
        epicenterX = epicenter.centerX();
        epicenterY = epicenter.centerY();
    } else {
        epicenterX = (left + right) / 2;
        epicenterY = (top + bottom) / 2;
    }

    float distance = distance(sceneRoot, viewCenterX, viewCenterY, epicenterX, epicenterY, left, top, right,
            bottom);
    float maxDistance = getMaxDistance(sceneRoot);
    float distanceFraction = distance / maxDistance;

    long duration = transition.getDuration();
    if (duration < 0) {
        duration = 300;
    }

    return Math.round(duration * directionMultiplier / mPropagationSpeed * distanceFraction);
}