下面列出了android.support.v4.view.ViewCompat#setScaleY ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Hide the label
*/
private void hideLabel(boolean animate) {
if (animate) {
float scale = mEditText.getTextSize() / mLabel.getTextSize();
ViewCompat.setScaleX(mLabel, 1f);
ViewCompat.setScaleY(mLabel, 1f);
ViewCompat.setTranslationY(mLabel, 0f);
ViewCompat.animate(mLabel)
.translationY(mLabel.getHeight())
.setDuration(ANIMATION_DURATION)
.scaleX(scale)
.scaleY(scale)
.setListener(new ViewPropertyAnimatorListenerAdapter() {
@Override
public void onAnimationEnd(View view) {
mLabel.setVisibility(INVISIBLE);
mEditText.setHint(mHint);
}
})
.setInterpolator(mInterpolator).start();
} else {
mLabel.setVisibility(INVISIBLE);
mEditText.setHint(mHint);
}
}
/**
* Hide the label
*/
private void hideLabel(boolean animate) {
if (animate) {
float scale = mEditText.getTextSize() / mLabel.getTextSize();
ViewCompat.setScaleX(mLabel, 1f);
ViewCompat.setScaleY(mLabel, 1f);
ViewCompat.setTranslationY(mLabel, 0f);
ViewCompat.animate(mLabel)
.translationY(mLabel.getHeight())
.setDuration(ANIMATION_DURATION)
.scaleX(scale)
.scaleY(scale)
.setListener(new ViewPropertyAnimatorListenerAdapter() {
@Override
public void onAnimationEnd(View view) {
mLabel.setVisibility(INVISIBLE);
mEditText.setHint(mHint);
}
})
.setInterpolator(mInterpolator).start();
} else {
mLabel.setVisibility(INVISIBLE);
mEditText.setHint(mHint);
}
}
public static void resetPageTransformer(List<? extends View> views) {
if (views == null) {
return;
}
for (View view : views) {
view.setVisibility(View.VISIBLE);
ViewCompat.setAlpha(view, 1);
ViewCompat.setPivotX(view, view.getMeasuredWidth() * 0.5f);
ViewCompat.setPivotY(view, view.getMeasuredHeight() * 0.5f);
ViewCompat.setTranslationX(view, 0);
ViewCompat.setTranslationY(view, 0);
ViewCompat.setScaleX(view, 1);
ViewCompat.setScaleY(view, 1);
ViewCompat.setRotationX(view, 0);
ViewCompat.setRotationY(view, 0);
ViewCompat.setRotation(view, 0);
}
}
/**
* Pre API 11, this does an alpha animation.
* @param progress
*/
private void setAnimationProgress(float progress) {
if (isAlphaUsedForScale()) {
setColorViewAlpha((int) (progress * MAX_ALPHA));
} else {
ViewCompat.setScaleX(mCircleView, progress);
ViewCompat.setScaleY(mCircleView, progress);
}
}
@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);
}
@Override
public void onPull(MaterialRefreshLayout materialRefreshLayout, float fraction) {
if(materialWaveView != null)
{
materialWaveView.onPull(materialRefreshLayout, fraction);
}
if(circleProgressBar != null)
{
circleProgressBar.onPull(materialRefreshLayout, fraction);
float a = Util.limitValue(1,fraction);
ViewCompat.setScaleX(circleProgressBar, 1);
ViewCompat.setScaleY(circleProgressBar, 1);
ViewCompat.setAlpha(circleProgressBar, a);
}
}
@Override
public void onPull(MaterialRefreshLayout materialRefreshLayout, float fraction) {
if (materialWaveView != null) {
materialWaveView.onPull(materialRefreshLayout, fraction);
}
if (circleProgressBar != null) {
circleProgressBar.onPull(materialRefreshLayout, fraction);
float a = Util.limitValue(1, fraction);
ViewCompat.setScaleX(circleProgressBar, 1);
ViewCompat.setScaleY(circleProgressBar, 1);
ViewCompat.setAlpha(circleProgressBar, a);
}
}
@Override
public void onPull(MaterialRefreshLayout materialRefreshLayout, float fraction) {
if (materialWaveView != null) {
materialWaveView.onPull(materialRefreshLayout, fraction);
}
if (circleProgressBar != null) {
circleProgressBar.onPull(materialRefreshLayout, fraction);
float a = Util.limitValue(1, fraction);
ViewCompat.setScaleX(circleProgressBar, 1);
ViewCompat.setScaleY(circleProgressBar, 1);
ViewCompat.setAlpha(circleProgressBar, a);
}
}
@Override
public void onPullReleasing(float fraction, float maxHeadHeight, float headHeight) {
mIsBeingDragged = false;
if (fraction >= 1f) {
ViewCompat.setScaleX(mCircleView, 1f);
ViewCompat.setScaleY(mCircleView, 1f);
} else {
ViewCompat.setScaleX(mCircleView, fraction);
ViewCompat.setScaleY(mCircleView, fraction);
}
}
@Override
public void onComlete(MaterialRefreshLayout materialRefreshLayout) {
if (materialWaveView != null) {
materialWaveView.onComlete(materialRefreshLayout);
}
if (circleProgressBar != null) {
circleProgressBar.onComlete(materialRefreshLayout);
ViewCompat.setTranslationY(circleProgressBar, 0);
ViewCompat.setScaleX(circleProgressBar, 0);
ViewCompat.setScaleY(circleProgressBar, 0);
}
}
private void mainViewUpdate(double currentValue) {
float ratio = (float) SpringUtil.mapValueFromRangeToRange(currentValue, 0, 1,
1, smallRatio);
ViewCompat.setScaleX(mainView, ratio);
ViewCompat.setScaleY(mainView, ratio);
ViewCompat.setAlpha(mainView, ratio);
}
@Override
protected void onTransform(View view, float position) {
if (position <= 0f) {
ViewCompat.setTranslationX(view,0f);
ViewCompat.setScaleX(view,1f);
ViewCompat.setScaleY(view,1f);
} else if (position <= 1f) {
final float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
ViewCompat.setAlpha(view,1-position);
ViewCompat.setPivotY(view,0.5f * view.getHeight());
ViewCompat.setTranslationX(view,view.getWidth() * - position);
ViewCompat.setScaleX(view,scaleFactor);
ViewCompat.setScaleY(view, scaleFactor);
}
}
@Override
public void onPullReleasing(float fraction, float maxHeadHeight, float headHeight) {
mIsBeingDragged = false;
if (fraction >= 1f) {
ViewCompat.setScaleX(mCircleView, 1f);
ViewCompat.setScaleY(mCircleView, 1f);
} else {
ViewCompat.setScaleX(mCircleView, fraction);
ViewCompat.setScaleY(mCircleView, fraction);
}
}
@Override
public void onPull(MaterialRefreshLayout materialRefreshLayout, float fraction) {
if (materialWaveView != null) {
materialWaveView.onPull(materialRefreshLayout, fraction);
}
if (circleProgressBar != null) {
circleProgressBar.onPull(materialRefreshLayout, fraction);
float a = Util.limitValue(1, fraction);
ViewCompat.setScaleX(circleProgressBar, a);
ViewCompat.setScaleY(circleProgressBar, a);
ViewCompat.setAlpha(circleProgressBar, a);
}
}
@Override
public void onComlete(MaterialRefreshLayout materialRefreshLayout) {
if (materialWaveView != null) {
materialWaveView.onComlete(materialRefreshLayout);
}
if (circleProgressBar != null) {
circleProgressBar.onComlete(materialRefreshLayout);
ViewCompat.setTranslationY(circleProgressBar, 0);
ViewCompat.setScaleX(circleProgressBar, 0);
ViewCompat.setScaleY(circleProgressBar, 0);
}
}
@Override
protected void prepareAnimateAdd(RecyclerView.ViewHolder holder) {
retrieveOriginalScale(holder);
ViewCompat.setScaleX(holder.itemView, mInitialScaleX);
ViewCompat.setScaleY(holder.itemView, mInitialScaleY);
}
public void scaleWithKeepingAspectRatio(float scale) {
ViewCompat.setScaleX(this, scale);
ViewCompat.setScaleY(this, scale);
}
@Override
protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
ViewCompat.setScaleX(holder.itemView, 0);
ViewCompat.setScaleY(holder.itemView, 0);
}
@Override
protected void preAnimateAddImpl(RecyclerView.ViewHolder holder) {
ViewCompat.setPivotX(holder.itemView, 0);
ViewCompat.setScaleX(holder.itemView, 0);
ViewCompat.setScaleY(holder.itemView, 0);
}
private void selectShowAnimation(boolean showDialog) {
if (mActivityContentView == null || isAnimating)
return;
if (showDialog) {
mActivityContentView.addView(GearLoadingLayout.this);
}
this.showDialog = showDialog;
float from = 0f;
float to = 0f;
boolean xAxis = false;
boolean scaleDialog = false;
switch (mShowMode) {
case TOP:
from = -mDialogHeight;
to = 0;
break;
case BOTTOM:
from = mDialogHeight;
to = 0;
break;
case LEFT:
from = -mDialogWidth;
to = 0;
xAxis = true;
break;
case RIGHT:
from = mDialogWidth;
to = 0;
xAxis = true;
break;
case CENTER:
scaleDialog = true;
break;
default:
break;
}
setGearLayoutWrapperGravity();
applyStyle();
start();
if (scaleDialog) {
ViewCompat.setScaleX(mGearLayoutWrapper, showDialog ? 0 : 1);
ViewCompat.setScaleY(mGearLayoutWrapper, showDialog ? 0 : 1);
ViewCompat.animate(mGearLayoutWrapper).scaleX(showDialog ? 1 : 0).scaleY(showDialog ? 1 : 0).setDuration(showDialogDuration).withStartAction(startAction).withEndAction(endAction).start();
} else {
if (!xAxis) {
ViewCompat.setTranslationY(mGearLayoutWrapper, showDialog ? from : to);
ViewCompat.animate(mGearLayoutWrapper).translationY(showDialog ? to : from).setDuration(showDialogDuration).withStartAction(startAction).withEndAction(endAction).start();
} else {
ViewCompat.setTranslationX(mGearLayoutWrapper, showDialog ? from : to);
ViewCompat.animate(mGearLayoutWrapper).translationX(showDialog ? to : from).setDuration(showDialogDuration).withStartAction(startAction).withEndAction(endAction).start();
}
}
ViewCompat.setAlpha(mMainBackground, showDialog ? 0 : isEnableBlur ? 1 : mMainBackgroundAlpha);
ViewCompat.animate(mMainBackground).alpha(showDialog ? isEnableBlur ? 1 : mMainBackgroundAlpha : 0).setDuration(showDialogDuration).start();
}