Java Code Examples for android.view.ViewPropertyAnimator#scaleX()

The following examples show how to use android.view.ViewPropertyAnimator#scaleX() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElasticDragDismissDelegate.java    From ElasticDragDismissLayout with Apache License 2.0 6 votes vote down vote up
public void onStopNestedScroll(View child) {
    // if the drag is too fast it probably was not an intentional drag but a fling, don't dismiss
    final long dragTime = System.currentTimeMillis() - scrollStartTimestamp;
    if (Math.abs(totalDrag) >= dragDismissDistance && dragTime > DRAG_DURATION_BUFFER) {
        dispatchDismissCallback();
    } else { // settle back to natural position
        ViewPropertyAnimator animator = mViewGroup.animate()
                .translationY(0f)
                .scaleY(1f)
                .setDuration(200L)
                .setInterpolator(new FastOutSlowInInterpolator())
                .setListener(null);
        if (enableScaleX) {
            animator.scaleX(1f);
        }

        animator.start();

        totalDrag = 0;
        draggingDown = draggingUp = false;
        dispatchDragCallback(0f, 0f, 0f, 0f);
    }
}
 
Example 2
Source File: FriendOverviewFragment.java    From repay-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
	super.onActivityCreated(savedInstanceState);

	mShareBtn = (Button) getView().findViewById(R.id.share);
	mFriendPic = (RoundedImageView) getView().findViewById(R.id.friend_image);
	mTotalOwed = (TextView) getView().findViewById(R.id.amount);
	mTotalOwedPrefix = (TextView) getView().findViewById(R.id.owe_status);
	mShareBtn.setOnClickListener(this);

	// Animate the UI into view
	mFriendPic.setScaleX(0f);
	mFriendPic.setScaleY(0f);
	ViewPropertyAnimator animator = mFriendPic.animate();
	animator.scaleX(1f);
	animator.scaleY(1f);
	animator.setDuration(500);
	animator.start();
}
 
Example 3
Source File: PhoneArithmetics.java    From ChromeLikeTabSwitcher with Apache License 2.0 5 votes vote down vote up
@Override
public final void animateScale(@NonNull final Axis axis,
                               @NonNull final ViewPropertyAnimator animator,
                               final float scale) {
    Condition.INSTANCE.ensureNotNull(axis, "The axis may not be null");
    Condition.INSTANCE.ensureNotNull(animator, "The animator may not be null");

    if (getOrientationInvariantAxis(axis) == Axis.DRAGGING_AXIS) {
        animator.scaleY(scale);
    } else {
        animator.scaleX(scale);
    }
}
 
Example 4
Source File: g.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public com.nineoldandroids.view.ViewPropertyAnimator scaleX(float f)
{
    ViewPropertyAnimator viewpropertyanimator = (ViewPropertyAnimator)b.get();
    if (viewpropertyanimator != null)
    {
        viewpropertyanimator.scaleX(f);
    }
    return this;
}
 
Example 5
Source File: AnimateableDialogDecorator.java    From AndroidMaterialDialog with Apache License 2.0 4 votes vote down vote up
/**
 * Configures an animator, which should be used to show the dialog using a rectangular reveal
 * animation.
 *
 * @param animatedView
 *         The animated view as an instance of the class {@link View}. The view may not be null
 * @param animation
 *         The animation as an instance of the class {@link RectangleRevealAnimation}. The
 *         animation may not be null
 * @param animator
 *         The animator, which should be configured, as an instance of the class {@link
 *         ViewPropertyAnimator}. The animator may not be null
 */
private void configureShowAnimator(@NonNull final View animatedView,
                                   @NonNull final RectangleRevealAnimation animation,
                                   @NonNull final ViewPropertyAnimator animator) {
    int horizontalWindowInset =
            getDialog().getWindowInsetLeft() + getDialog().getWindowInsetRight();
    int verticalWindowInset =
            getDialog().getWindowInsetTop() + getDialog().getWindowInsetBottom();
    float translationX = 0;
    float translationY = 0;

    if (animation.getX() != null) {
        translationX = animation.getX() - animatedView.getLeft() - horizontalWindowInset;
    }

    if (animation.getY() != null) {
        translationY = animation.getY() - animatedView.getTop() - verticalWindowInset;
    }

    if (animation.getWidth() != null) {
        int viewWidth = animatedView.getWidth() - horizontalWindowInset;
        translationX -= (float) (viewWidth - animation.getWidth()) / 2f;
        animatedView.setScaleX((float) animation.getWidth() / (float) viewWidth);
        animator.scaleX(1);
    }

    if (animation.getHeight() != null) {
        int viewHeight = animatedView.getHeight() - verticalWindowInset;
        translationY -= (float) (viewHeight - animation.getHeight()) / 2f;
        animatedView.setScaleY((float) animation.getHeight() / (float) viewHeight);
        animator.scaleY(1);
    }

    if (animation.getAlpha() != null) {
        animatedView.setAlpha(animation.getAlpha());
        animator.alpha(1);
    }

    if (translationX != 0) {
        animatedView.setTranslationX(translationX);
        animator.translationX(0);
    }

    if (translationY != 0) {
        animatedView.setTranslationY(translationY);
        animator.translationY(0);
    }
}
 
Example 6
Source File: AnimateableDialogDecorator.java    From AndroidMaterialDialog with Apache License 2.0 4 votes vote down vote up
/**
 * Configures an animator, which should be used to hide the dialog using a rectangular reveal
 * animation.
 *
 * @param animatedView
 *         The animated view as an instance of the class {@link View}. The view may not be null
 * @param animation
 *         The animation as an instance of the class {@link RectangleRevealAnimation}. The
 *         animation may not be null
 * @param animator
 *         The animator, which should be configured, as an instance of the class {@link
 *         ViewPropertyAnimator}. The animator may not be null
 */
private void configureHideAnimator(@NonNull final View animatedView,
                                   @NonNull final RectangleRevealAnimation animation,
                                   @NonNull final ViewPropertyAnimator animator) {
    int horizontalWindowInset =
            getDialog().getWindowInsetLeft() + getDialog().getWindowInsetRight();
    int verticalWindowInset =
            getDialog().getWindowInsetTop() + getDialog().getWindowInsetBottom();
    float translationX = 0;
    float translationY = 0;

    if (animation.getX() != null) {
        translationX = animation.getX() - animatedView.getLeft() - horizontalWindowInset;
    }

    if (animation.getY() != null) {
        translationY = animation.getY() - animatedView.getTop() - verticalWindowInset;
    }

    if (animation.getWidth() != null) {
        int viewWidth = animatedView.getWidth() - horizontalWindowInset;
        translationX -= (float) (viewWidth - animation.getWidth()) / 2f;
        animator.scaleX((float) animation.getWidth() / (float) viewWidth);
    }

    if (animation.getHeight() != null) {
        int viewHeight = animatedView.getHeight() - verticalWindowInset;
        translationY -= (float) (viewHeight - animation.getHeight()) / 2f;
        animator.scaleY((float) animation.getHeight() / (float) viewHeight);
    }

    if (animation.getAlpha() != null) {
        animator.alpha(animation.getAlpha());
    }

    if (translationX != 0) {
        animator.translationX(translationX);
    }

    if (translationY != 0) {
        animator.translationY(translationY);
    }
}
 
Example 7
Source File: StartFragmentAdapter.java    From repay-android with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    if (v == null) {
        LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(layoutId, null);
    }
    Friend friend = friends.get(position);
    if (friend != null) {
        // TODO Implement View holder pattern
        TextView name = (TextView) v.findViewById(R.id.fragment_start_friendslist_item_name);
        TextView amount = (TextView) v.findViewById(R.id.fragment_start_friendslist_item_amount);
        final RoundedImageView pic = (RoundedImageView) v.findViewById(R.id.fragment_start_friendslist_item_pic);

        v.setTag(friend); // Stored as a tag to be retrieved later for OnItemClickListener

        Log.i(TAG, "Now retrieving contact image");
        ImageLoader.getInstance().displayImage(friend.getLookupURI(), pic, Application.getImageOptions());

        name.setText(friend.getName());

        if (friend.getDebt().compareTo(BigDecimal.ZERO) < 0) {
            pic.setOuterColor(mIOweThemColour);
            amount.setText(SettingsFragment.getCurrencySymbol(mContext) +
                    SettingsFragment.getFormattedAmount(friend.getDebt().negate()));
        } else {
            pic.setOuterColor(mTheyOweMeColour);
            amount.setText(SettingsFragment.getCurrencySymbol(mContext) +
                    SettingsFragment.getFormattedAmount(friend.getDebt()));
        }
    }

    v.setScaleX(0f);
    v.setScaleY(0f);
    v.setAlpha(0f);
    ViewPropertyAnimator animate = v.animate();
    animate.scaleX(1f);
    animate.scaleY(1f);
    animate.alpha(1f);
    animate.setDuration(500);
    animate.start();
    return v;
}