下面列出了android.support.v4.view.ViewCompat#setScaleX ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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
public void handleRightPage(View view, float position) {
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);
}
}
@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
public void handleLeftPage(View view, float position) {
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);
ViewCompat.setAlpha(view, 1 + position);
}
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);
v.setPivotY(v.getMeasuredHeight() / 2);
ViewCompat.setPivotX(v, v.getMeasuredWidth() / 2);
ViewCompat.animate(v).setInterpolator(null);
}
@Override
public void onBegin(MaterialRefreshLayout materialRefreshLayout) {
if (materialWaveView != null) {
materialWaveView.onBegin(materialRefreshLayout);
}
if (circleProgressBar != null) {
ViewCompat.setScaleX(circleProgressBar, 0.001f);
ViewCompat.setScaleY(circleProgressBar, 0.001f);
circleProgressBar.onBegin(materialRefreshLayout);
}
}
@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);
}
}
/**
* 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);
}
}
private void setAnimationProgress(float progress) {
if (!usingDefaultHeader) {
progress = 1;
}
ViewCompat.setScaleX(mHeadViewContainer, progress);
ViewCompat.setScaleY(mHeadViewContainer, progress);
}
@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);
}
}
/**
* 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);
}
}
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);
// @TODO https://code.google.com/p/android/issues/detail?id=80863
ViewCompat.setPivotY(v, v.getMeasuredHeight() / 2);
// v.setPivotY(v.getMeasuredHeight() / 2);
ViewCompat.setPivotX(v, v.getMeasuredWidth() / 2);
ViewCompat.animate(v).setInterpolator(null);
}
@Override
public void handleLeftPage(View view, float position) {
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);
}
}
@Override
public void onBegin(MaterialRefreshLayout materialRefreshLayout) {
if (materialWaveView != null) {
materialWaveView.onBegin(materialRefreshLayout);
}
if (circleProgressBar != null) {
circleProgressBar.onBegin(materialRefreshLayout);
ViewCompat.setScaleX(circleProgressBar, 1);
ViewCompat.setScaleY(circleProgressBar, 1);
}
}
@Override
public void handleLeftPage(View view, float position) {
float scale = Math.max(mMinScale, 1 + position);
float vertMargin = view.getHeight() * (1 - scale) / 2;
float horzMargin = view.getWidth() * (1 - scale) / 2;
ViewCompat.setTranslationX(view, horzMargin - vertMargin / 2);
ViewCompat.setScaleX(view, scale);
ViewCompat.setScaleY(view, scale);
ViewCompat.setAlpha(view, mMinAlpha + (scale - mMinScale) / (1 - mMinScale) * (1 - mMinAlpha));
}
@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 onBegin(MaterialRefreshLayout materialRefreshLayout) {
if (materialWaveView != null) {
materialWaveView.onBegin(materialRefreshLayout);
}
if (circleProgressBar != null) {
ViewCompat.setScaleX(circleProgressBar, 0.001f);
ViewCompat.setScaleY(circleProgressBar, 0.001f);
circleProgressBar.onBegin(materialRefreshLayout);
}
}
/**
* 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 onPreAnimateAdd(RecyclerView.ViewHolder holder) {
ViewCompat.setScaleX(holder.itemView, 0);
ViewCompat.setScaleY(holder.itemView, 0);
//setAddDuration(1000);
}
@Override
protected void prepareAnimateAdd(RecyclerView.ViewHolder holder) {
retrieveOriginalScale(holder);
ViewCompat.setScaleX(holder.itemView, 0);
ViewCompat.setScaleY(holder.itemView, 0);
}