Java Code Examples for androidx.core.view.ViewCompat#setScaleY()

The following examples show how to use androidx.core.view.ViewCompat#setScaleY() . 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: MyPageTransform.java    From android with MIT License 6 votes vote down vote up
@Override
public void transformPage(View page, float position) {
    float scale = (position < 0)
            ? ((1 - SCALE_MAX) * position + 1)
            : ((SCALE_MAX - 1) * position + 1);
    float alpha = (position < 0)
            ? ((1 - ALPHA_MAX) * position + 1)
            : ((ALPHA_MAX - 1) * position + 1);
    //为了滑动过程中,page间距不变,这里做了处理
    if (position < 0) {
        ViewCompat.setPivotX(page, page.getWidth());
        ViewCompat.setPivotY(page, page.getHeight() / 2);
    } else {
        ViewCompat.setPivotX(page, 0);
        ViewCompat.setPivotY(page, page.getHeight() / 2);
    }
    ViewCompat.setScaleX(page, scale);
    ViewCompat.setScaleY(page, scale);
    ViewCompat.setAlpha(page, Math.abs(alpha));
}
 
Example 2
Source File: CustomSwipeRefreshLayout.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
/**
 * Pre API 11, this does an alpha animation.
 *
 * @param progress
 */
void setAnimationProgress(float progress) {
    if (isAlphaUsedForScale()) {
        setColorViewAlpha((int) (progress * MAX_ALPHA));
    } else {
        ViewCompat.setScaleX(mCircleView, progress);
        ViewCompat.setScaleY(mCircleView, progress);
    }
}
 
Example 3
Source File: IModeActivity.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
@Override
public void transformPage(View page, float position) {
    if (position < -1) {
        ViewCompat.setScaleY(page, 0.9f);
    } else if (position <= 1) {
        float scale = Math.max(0.9f, 1 - Math.abs(position));
        ViewCompat.setScaleY(page, scale);
    } else {
        ViewCompat.setScaleY(page, 0.9f);
    }
}
 
Example 4
Source File: IModeActivity.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
@Override
public void transformPage(View view, float position) {
    if (position < -1) {

    } else if (position <= 0) {
        ViewCompat.setTranslationX(view, -view.getWidth() * position);

        ViewCompat.setPivotX(view, view.getWidth() * 0.5f);
        ViewCompat.setPivotY(view, view.getHeight() * 0.5f);
        ViewCompat.setScaleX(view, 1 + position);
        ViewCompat.setScaleY(view, 1 + position);

        if (position < -0.95f) {
            ViewCompat.setAlpha(view, 0);
        } else {
            ViewCompat.setAlpha(view, 1);
        }
    } else if (position <= 1) {
        ViewCompat.setTranslationX(view, -view.getWidth() * position);

        ViewCompat.setPivotX(view, view.getWidth() * 0.5f);
        ViewCompat.setPivotY(view, view.getHeight() * 0.5f);
        ViewCompat.setScaleX(view, 1 - position);
        ViewCompat.setScaleY(view, 1 - position);

        if (position > 0.95f) {
            ViewCompat.setAlpha(view, 0);
        } else {
            ViewCompat.setAlpha(view, 1);
        }
    }
}
 
Example 5
Source File: FlipDownItemAnimator.java    From FlexibleAdapter with Apache License 2.0 5 votes vote down vote up
@Override
protected void onRemoveCanceled(ViewHolder holder) {
    ViewCompat.setRotationY(holder.itemView, 0);
    ViewCompat.setTranslationX(holder.itemView, 0);
    ViewCompat.setScaleX(holder.itemView, 1);
    ViewCompat.setScaleY(holder.itemView, 1);
}
 
Example 6
Source File: ViewHelper.java    From recyclerview-animators with Apache License 2.0 5 votes vote down vote up
public static void clear(View v) {
  ViewCompat.setAlpha(v, 1);
  ViewCompat.setScaleY(v, 1);
  ViewCompat.setScaleX(v, 1);
  ViewCompat.setTranslationY(v, 0);
  ViewCompat.setTranslationX(v, 0);
  ViewCompat.setRotation(v, 0);
  ViewCompat.setRotationY(v, 0);
  ViewCompat.setRotationX(v, 0);
  ViewCompat.setPivotY(v, v.getMeasuredHeight() / 2);
  ViewCompat.setPivotX(v, v.getMeasuredWidth() / 2);
  ViewCompat.animate(v).setInterpolator(null).setStartDelay(0);
}
 
Example 7
Source File: ScaleInBottomAnimator.java    From recyclerview-animators with Apache License 2.0 5 votes vote down vote up
@Override protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
  // @TODO https://code.google.com/p/android/issues/detail?id=80863
  //        ViewCompat.setPivotY(holder.itemView, holder.itemView.getHeight());
  holder.itemView.setPivotY(holder.itemView.getHeight());
  ViewCompat.setScaleX(holder.itemView, 0);
  ViewCompat.setScaleY(holder.itemView, 0);
}
 
Example 8
Source File: ScaleInTopAnimator.java    From recyclerview-animators with Apache License 2.0 5 votes vote down vote up
@Override protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
  // @TODO https://code.google.com/p/android/issues/detail?id=80863
  //        ViewCompat.setPivotY(holder.itemView, 0);
  holder.itemView.setPivotY(0);
  ViewCompat.setScaleX(holder.itemView, 0);
  ViewCompat.setScaleY(holder.itemView, 0);
}
 
Example 9
Source File: CustomSwipeRefreshLayout.java    From NewFastFrame with Apache License 2.0 4 votes vote down vote up
@SuppressLint("NewApi")
private void moveSpinner(float overscrollTop) {
    mProgress.showArrow(true);
    float originalDragPercent = overscrollTop / mTotalDragDistance;

    float dragPercent = Math.min(1f, Math.abs(originalDragPercent));
    float adjustedPercent = (float) Math.max(dragPercent - .4, 0) * 5 / 3;
    float extraOS = Math.abs(overscrollTop) - mTotalDragDistance;
    float slingshotDist = mUsingCustomStart ? mSpinnerOffsetEnd - mOriginalOffsetTop
            : mSpinnerOffsetEnd;
    float tensionSlingshotPercent = Math.max(0, Math.min(extraOS, slingshotDist * 2)
            / slingshotDist);
    float tensionPercent = (float) ((tensionSlingshotPercent / 4) - Math.pow(
            (tensionSlingshotPercent / 4), 2)) * 2f;
    float extraMove = (slingshotDist) * tensionPercent * 2;

    int targetY = mOriginalOffsetTop + (int) ((slingshotDist * dragPercent) + extraMove);
    // where 1.0f is a full circle
    if (mCircleView.getVisibility() != View.VISIBLE) {
        mCircleView.setVisibility(View.VISIBLE);
    }
    if (!mScale) {
        ViewCompat.setScaleX(mCircleView, 1f);
        ViewCompat.setScaleY(mCircleView, 1f);
    }

    if (mScale) {
        setAnimationProgress(Math.min(1f, overscrollTop / mTotalDragDistance));
    }
    if (overscrollTop < mTotalDragDistance) {
        if (mProgress.getAlpha() > STARTING_PROGRESS_ALPHA
                && !isAnimationRunning(mAlphaStartAnimation)) {
            // Animate the alpha
            startProgressAlphaStartAnimation();
        }
    } else {
        if (mProgress.getAlpha() < MAX_ALPHA && !isAnimationRunning(mAlphaMaxAnimation)) {
            // Animate the alpha
            startProgressAlphaMaxAnimation();
        }
    }
    float strokeStart = adjustedPercent * .8f;
    mProgress.setStartEndTrim(0f, Math.min(MAX_PROGRESS_ANGLE, strokeStart));
    mProgress.setArrowScale(Math.min(1f, adjustedPercent));

    float rotation = (-0.25f + .4f * adjustedPercent + tensionPercent * 2) * .5f;
    mProgress.setProgressRotation(rotation);
    setTargetOffsetTopAndBottom(targetY - mCurrentTargetOffsetTop, true /* requires update */);
}
 
Example 10
Source File: AdGoogleDisplaySupport.java    From UltimateRecyclerView with Apache License 2.0 4 votes vote down vote up
public static <T extends ViewGroup> void scale(T view, double scaleRatio) {
    ViewCompat.setScaleX(view, (float) scaleRatio);
    ViewCompat.setScaleY(view, (float) scaleRatio);
}
 
Example 11
Source File: ScaleInAnimator.java    From recyclerview-animators with Apache License 2.0 4 votes vote down vote up
@Override protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
  ViewCompat.setScaleX(holder.itemView, 0);
  ViewCompat.setScaleY(holder.itemView, 0);
}
 
Example 12
Source File: ScaleInLeftAnimator.java    From recyclerview-animators with Apache License 2.0 4 votes vote down vote up
@Override protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
  ViewCompat.setPivotX(holder.itemView, 0);
  ViewCompat.setScaleX(holder.itemView, 0);
  ViewCompat.setScaleY(holder.itemView, 0);
}
 
Example 13
Source File: ScaleInRightAnimator.java    From recyclerview-animators with Apache License 2.0 4 votes vote down vote up
@Override protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
  ViewCompat.setPivotX(holder.itemView, holder.itemView.getWidth());
  ViewCompat.setScaleX(holder.itemView, 0);
  ViewCompat.setScaleY(holder.itemView, 0);
}
 
Example 14
Source File: LandingAnimator.java    From recyclerview-animators with Apache License 2.0 4 votes vote down vote up
@Override protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
  ViewCompat.setAlpha(holder.itemView, 0);
  ViewCompat.setScaleX(holder.itemView, 1.5f);
  ViewCompat.setScaleY(holder.itemView, 1.5f);
}