Example usage for android.view View setBottom

List of usage examples for android.view View setBottom

Introduction

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

Prototype

public final void setBottom(int bottom) 

Source Link

Document

Sets the bottom position of this view relative to its parent.

Usage

From source file:Main.java

static public void setFrame(View v, Rect frame) {
    v.setTop(frame.top);//from  w w w.ja  va2  s .  com
    v.setLeft(frame.left);
    v.setBottom(frame.bottom);
    v.setRight(frame.right);
}

From source file:Main.java

static public void setPosition(View v, PointF p) {
    int w = v.getWidth();
    int h = v.getHeight();
    v.setLeft((int) p.x);
    v.setTop((int) p.y);
    v.setRight((int) p.x + w);
    v.setBottom((int) p.y + h);
}

From source file:com.chromium.fontinstaller.util.ViewUtils.java

public static void reveal(Activity activity, View view, View sourceView, int colorRes) {
    if (activity == null || view == null || sourceView == null)
        return;/*from   w ww  .  j a  v a2 s  .com*/
    if (isLollipop()) {
        final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) activity.getWindow().getDecorView()
                .getOverlay();

        final Rect displayRect = new Rect();
        view.getGlobalVisibleRect(displayRect);

        // Make reveal cover the display and status bar.
        final View revealView = new View(activity);
        revealView.setTop(displayRect.top);
        revealView.setBottom(displayRect.bottom);
        revealView.setLeft(displayRect.left);
        revealView.setRight(displayRect.right);
        revealView.setBackgroundColor(ContextCompat.getColor(activity, colorRes));
        groupOverlay.add(revealView);

        final int[] clearLocation = new int[2];
        sourceView.getLocationInWindow(clearLocation);
        clearLocation[0] += sourceView.getWidth() / 2;
        clearLocation[1] += sourceView.getHeight() / 2;

        final int revealCenterX = clearLocation[0] - revealView.getLeft();
        final int revealCenterY = clearLocation[1] - revealView.getTop();

        final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2);
        final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2);
        final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2);
        final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2));

        try {
            final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX,
                    revealCenterY, 0.0f, revealRadius);
            revealAnimator
                    .setDuration(activity.getResources().getInteger(android.R.integer.config_mediumAnimTime));

            final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
            alphaAnimator
                    .setDuration(activity.getResources().getInteger(android.R.integer.config_shortAnimTime));
            alphaAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.abc_fade_in));
                    view.setVisibility(View.VISIBLE);
                }
            });

            final AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.play(revealAnimator).before(alphaAnimator);
            animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
            animatorSet.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animator) {
                    groupOverlay.remove(revealView);
                }
            });

            animatorSet.start();
        } catch (IllegalStateException e) {
            Timber.i("View is detached - not animating");
        }
    } else {
        view.setVisibility(View.VISIBLE);
    }
}

From source file:com.android.clear.reminder.AnimatorUtils.java

/**
 * Returns an animator that animates the bounds of a single view.
 *///from   www .jav a2  s . com
public static Animator getBoundsAnimator(View view, int fromLeft, int fromTop, int fromRight, int fromBottom,
        int toLeft, int toTop, int toRight, int toBottom) {
    view.setLeft(fromLeft);
    view.setTop(fromTop);
    view.setRight(fromRight);
    view.setBottom(fromBottom);

    return ObjectAnimator.ofPropertyValuesHolder(view, PropertyValuesHolder.ofInt(VIEW_LEFT, toLeft),
            PropertyValuesHolder.ofInt(VIEW_TOP, toTop), PropertyValuesHolder.ofInt(VIEW_RIGHT, toRight),
            PropertyValuesHolder.ofInt(VIEW_BOTTOM, toBottom));
}

From source file:com.xujun.contralayout.utils.AnimatorUtil.java

public static void show(final View view, int start, int end) {
    final int height = view.getHeight();
    final ValueAnimator animator = ValueAnimator.ofInt(start, end);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override//w  w w .java 2 s  .  c  o m
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int value = (Integer) animator.getAnimatedValue();
            Log.i(TAG, "onAnimationUpdate: value=" + value);
            view.setTop(value);
            view.setBottom(value + height);
        }
    });
    view.setVisibility(View.VISIBLE);
    animator.setDuration(200);
    animator.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
    animator.start();
}

From source file:com.rockspoon.rockandui.Components.RelativeLayoutWithSwipe.java

public void setTopView(View view) {
    id = view.getId();//from  w w w. j  a v a  2 s . c  o m
    view.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop,
                int oldRight, int oldBottom) {
            if (isMoving()) {
                v.setTop(oldTop);
                v.setBottom(oldBottom);
                v.setLeft(oldLeft);
                v.setRight(oldRight);
            }
        }
    });
}

From source file:com.hamzahrmalik.calculator2.Calculator.java

private void reveal(View sourceView, int colorRes, AnimatorListener listener) {
    final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) getWindow().getDecorView().getOverlay();

    final Rect displayRect = new Rect();
    mDisplayView.getGlobalVisibleRect(displayRect);

    // Make reveal cover the display and status bar.
    final View revealView = new View(this);
    revealView.setBottom(displayRect.bottom);
    revealView.setLeft(displayRect.left);
    revealView.setRight(displayRect.right);
    revealView.setBackgroundColor(getResources().getColor(colorRes));
    groupOverlay.add(revealView);/*from   ww w  . j  a va  2  s . c  o m*/

    final int[] clearLocation = new int[2];
    sourceView.getLocationInWindow(clearLocation);
    clearLocation[0] += sourceView.getWidth() / 2;
    clearLocation[1] += sourceView.getHeight() / 2;

    final int revealCenterX = clearLocation[0] - revealView.getLeft();
    final int revealCenterY = clearLocation[1] - revealView.getTop();

    final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2);
    final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2);
    final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2);
    final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2));

    final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
    alphaAnimator.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animator) {
            groupOverlay.remove(revealView);
            mCurrentAnimator = null;
        }
    });

    mResultEditText.setText("");
    mFormulaEditText.setText("");
    mCurrentAnimator = animatorSet;
    animatorSet.start();

}

From source file:com.pitchedapps.primenumbercalculator.Calculator.java

License:asdf

private void reveal(View sourceView, AnimatorListener listener) {
    final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) getWindow().getDecorView().getOverlay();

    final Rect displayRect = new Rect();
    mDisplayView.getGlobalVisibleRect(displayRect);

    // Make reveal cover the display and status bar.
    final View revealView = new View(this);
    revealView.setBottom(displayRect.bottom);
    revealView.setLeft(displayRect.left);
    revealView.setRight(displayRect.right);
    revealView.setBackgroundColor(themeClearAccent);
    groupOverlay.add(revealView);/*  w w  w  . jav  a 2 s.  c om*/

    final int[] clearLocation = new int[2];
    sourceView.getLocationInWindow(clearLocation);
    clearLocation[0] += sourceView.getWidth() / 2;
    clearLocation[1] += sourceView.getHeight() / 2;

    final int revealCenterX = clearLocation[0] - revealView.getLeft();
    final int revealCenterY = clearLocation[1] - revealView.getTop();

    final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2);
    final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2);
    final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2);
    final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2));

    final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX,
            revealCenterY, 0.0f, revealRadius);
    revealAnimator.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime));

    final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
    alphaAnimator.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));
    alphaAnimator.addListener(listener);

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(revealAnimator).before(alphaAnimator);
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            groupOverlay.remove(revealView);
            mCurrentAnimator = null;
        }
    });

    mCurrentAnimator = animatorSet;
    animatorSet.start();
}

From source file:com.android.calculator2.Calculator.java

private void reveal(View sourceView, int colorRes, AnimatorListener listener) {
    final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) getWindow().getDecorView().getOverlay();

    final Rect displayRect = new Rect();
    mDisplayView.getGlobalVisibleRect(displayRect);

    // Make reveal cover the display and status bar.
    final View revealView = new View(this);
    revealView.setBottom(displayRect.bottom);
    revealView.setLeft(displayRect.left);
    revealView.setRight(displayRect.right);
    revealView.setBackgroundColor(getResources().getColor(colorRes));
    groupOverlay.add(revealView);/* w ww  .j a v  a 2s  .c om*/

    final int[] clearLocation = new int[2];
    sourceView.getLocationInWindow(clearLocation);
    clearLocation[0] += sourceView.getWidth() / 2;
    clearLocation[1] += sourceView.getHeight() / 2;

    final int revealCenterX = clearLocation[0] - revealView.getLeft();
    final int revealCenterY = clearLocation[1] - revealView.getTop();

    final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2);
    final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2);
    final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2);
    final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2));

    final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX,
            revealCenterY, 0.0f, revealRadius);
    revealAnimator.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime));
    revealAnimator.addListener(listener);

    final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
    alphaAnimator.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(revealAnimator).before(alphaAnimator);
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            groupOverlay.remove(revealView);
            mCurrentAnimator = null;
        }
    });

    mCurrentAnimator = animatorSet;
    animatorSet.start();
}

From source file:org.chromium.chrome.browser.widget.animation.FocusAnimator.java

private void startAnimator(final Runnable callback) {
    // Don't animate anything if the number of children changed.
    if (mInitialNumberOfChildren != mLayout.getChildCount()) {
        finishAnimation(callback);/*from  w w  w.ja va2 s  .  c o m*/
        return;
    }

    // Don't animate if children are already all in the correct places.
    boolean isAnimationNecessary = false;
    ArrayList<Integer> finalChildTops = calculateChildTops();
    for (int i = 0; i < finalChildTops.size() && !isAnimationNecessary; i++) {
        isAnimationNecessary |= finalChildTops.get(i).compareTo(mInitialTops.get(i)) != 0;
    }
    if (!isAnimationNecessary) {
        finishAnimation(callback);
        return;
    }

    // Animate each child moving and changing size to match their final locations.
    ArrayList<Animator> animators = new ArrayList<Animator>();
    ValueAnimator childAnimator = ValueAnimator.ofFloat(0f, 1f);
    animators.add(childAnimator);
    for (int i = 0; i < mLayout.getChildCount(); i++) {
        // The child is already where it should be.
        if (mInitialTops.get(i).compareTo(finalChildTops.get(i)) == 0
                && mInitialTops.get(i + 1).compareTo(finalChildTops.get(i + 1)) == 0) {
            continue;
        }

        final View child = mLayout.getChildAt(i);
        final int translationDifference = mInitialTops.get(i) - finalChildTops.get(i);
        final int oldHeight = mInitialTops.get(i + 1) - mInitialTops.get(i);
        final int newHeight = finalChildTops.get(i + 1) - finalChildTops.get(i);

        // Translate the child to its new place while changing where its bottom is drawn to
        // animate the child changing height without causing another layout.
        childAnimator.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float progress = (Float) animation.getAnimatedValue();
                child.setTranslationY(translationDifference * (1f - progress));

                if (oldHeight != newHeight) {
                    float animatedHeight = oldHeight * (1f - progress) + newHeight * progress;
                    child.setBottom(child.getTop() + (int) animatedHeight);
                }
            }
        });

        // Explicitly place the child in its final position in the end.
        childAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animator) {
                child.setTranslationY(0);
                child.setBottom(child.getTop() + newHeight);
            }
        });
    }

    // Animate the height of the container itself changing.
    int oldContainerHeight = mInitialTops.get(mInitialTops.size() - 1);
    int newContainerHeight = finalChildTops.get(finalChildTops.size() - 1);
    ValueAnimator layoutAnimator = ValueAnimator.ofInt(oldContainerHeight, newContainerHeight);
    layoutAnimator.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mLayout.setBottom(((Integer) animation.getAnimatedValue()));
            requestChildFocus();
        }
    });
    animators.add(layoutAnimator);

    // Set up and kick off the animation.
    AnimatorSet animator = new AnimatorSet();
    animator.setDuration(ANIMATION_LENGTH_MS);
    animator.setInterpolator(new LinearOutSlowInInterpolator());
    animator.playTogether(animators);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            finishAnimation(callback);

            // Request a layout to put everything in the right final place.
            mLayout.requestLayout();
        }
    });
    animator.start();
}