本文整理匯總了Java中android.animation.Keyframe類的典型用法代碼示例。如果您正苦於以下問題:Java Keyframe類的具體用法?Java Keyframe怎麽用?Java Keyframe使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Keyframe類屬於android.animation包,在下文中一共展示了Keyframe類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPulseAnimator
import android.animation.Keyframe; //導入依賴的package包/類
/**
* Render an animator to pulsate a view in place.
*
* @param labelToAnimate the view to pulsate.
* @return The animator object. Use .start() to begin.
*/
public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio,
float increaseRatio) {
Keyframe k0 = Keyframe.ofFloat(0f, 1f);
Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio);
Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio);
Keyframe k3 = Keyframe.ofFloat(1f, 1f);
@SuppressLint("ObjectAnimatorBinding") PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3);
@SuppressLint("ObjectAnimatorBinding") PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3);
ObjectAnimator pulseAnimator =
ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY);
pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION);
return pulseAnimator;
}
示例2: getDisappearAnimator
import android.animation.Keyframe; //導入依賴的package包/類
public ObjectAnimator getDisappearAnimator() {
if (!mIsInitialized || !mDrawValuesReady) {
Log.e(TAG, "RadialSelectorView was not ready for animation.");
return null;
}
Keyframe kf0, kf1, kf2;
float midwayPoint = 0.2f;
int duration = 500;
kf0 = Keyframe.ofFloat(0f, 1);
kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
"animationRadiusMultiplier", kf0, kf1, kf2);
kf0 = Keyframe.ofFloat(0f, 1f);
kf1 = Keyframe.ofFloat(1f, 0f);
PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);
ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
this, radiusDisappear, fadeOut).setDuration(duration);
disappearAnimator.addUpdateListener(mInvalidateUpdateListener);
return disappearAnimator;
}
示例3: getPulseAnimator
import android.animation.Keyframe; //導入依賴的package包/類
/**
* Render an animator to pulsate a view in place.
* @param labelToAnimate the view to pulsate.
* @return The animator object. Use .start() to begin.
*/
public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio,
float increaseRatio) {
Keyframe k0 = Keyframe.ofFloat(0f, 1f);
Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio);
Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio);
Keyframe k3 = Keyframe.ofFloat(1f, 1f);
PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3);
PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3);
ObjectAnimator pulseAnimator =
ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY);
pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION);
return pulseAnimator;
}
示例4: nope
import android.animation.Keyframe; //導入依賴的package包/類
public static ObjectAnimator nope(View view) {
int delta = view.getResources().getDimensionPixelOffset(R.dimen.height_16px);
PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X,
Keyframe.ofFloat(0f, 0),
Keyframe.ofFloat(.10f, -delta),
Keyframe.ofFloat(.26f, delta),
Keyframe.ofFloat(.42f, -delta),
Keyframe.ofFloat(.58f, delta),
Keyframe.ofFloat(.74f, -delta),
Keyframe.ofFloat(.90f, delta),
Keyframe.ofFloat(1f, 0f)
);
return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).
setDuration(500);
}
示例5: getReappearAnimator
import android.animation.Keyframe; //導入依賴的package包/類
public ObjectAnimator getReappearAnimator() {
if (this.mIsInitialized && this.mDrawValuesReady) {
int totalDuration = (int) (((float) 500) * (1.0f + ChartZoomer.ZOOM_AMOUNT));
float delayPoint = (((float) 500) * ChartZoomer.ZOOM_AMOUNT) / ((float) totalDuration);
float midwayPoint = 1.0f - ((1.0f - delayPoint) * 0.2f);
Keyframe kf0 = Keyframe.ofFloat(0.0f, this.mTransitionEndRadiusMultiplier);
Keyframe kf1 = Keyframe.ofFloat(delayPoint, this.mTransitionEndRadiusMultiplier);
Keyframe kf2 = Keyframe.ofFloat(midwayPoint, this.mTransitionMidRadiusMultiplier);
Keyframe kf3 = Keyframe.ofFloat(1.0f, 1.0f);
PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe
("animationRadiusMultiplier", new Keyframe[]{kf0, kf1, kf2, kf3});
kf0 = Keyframe.ofFloat(0.0f, 0.0f);
kf1 = Keyframe.ofFloat(delayPoint, 0.0f);
kf2 = Keyframe.ofFloat(1.0f, 1.0f);
PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", new
Keyframe[]{kf0, kf1, kf2});
ObjectAnimator reappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, new
PropertyValuesHolder[]{radiusReappear, fadeIn}).setDuration((long) totalDuration);
reappearAnimator.addUpdateListener(this.mInvalidateUpdateListener);
return reappearAnimator;
}
Log.e(TAG, "RadialSelectorView was not ready for animation.");
return null;
}
示例6: startIntroTextAnimation
import android.animation.Keyframe; //導入依賴的package包/類
private void startIntroTextAnimation() {
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Animator introAnimator = AnimatorInflater.loadAnimator(this, R.animator.intro);
introAnimator.setTarget(introTextView);
introAnimator.start();
} else {
Keyframe kf0 = Keyframe.ofFloat(0f, 0);
Keyframe kf1 = Keyframe.ofFloat(.2f, 1);
Keyframe kf2 = Keyframe.ofFloat(.9f, 1);
Keyframe kf3 = Keyframe.ofFloat(1f, 0);
PropertyValuesHolder pvh = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2, kf3);
ObjectAnimator alphaAnimator = ObjectAnimator.ofPropertyValuesHolder(introTextView, pvh);
alphaAnimator.setInterpolator(new DecelerateInterpolator());
alphaAnimator.setDuration(6000).setStartDelay(1000);
alphaAnimator.start();
}
}
示例7: startLogoAnimation
import android.animation.Keyframe; //導入依賴的package包/類
private void startLogoAnimation() {
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Animator logoAnimator = AnimatorInflater.loadAnimator(this, R.animator.logo);
logoAnimator.setTarget(logoView);
logoAnimator.start();
} else {
AnimatorSet animatorSet = new AnimatorSet();
PropertyValuesHolder pvh = PropertyValuesHolder.ofKeyframe("alpha",
Keyframe.ofFloat(0f, 1),
Keyframe.ofFloat(.5f, 1),
Keyframe.ofFloat(1f, 0));
ObjectAnimator alphaAnimator = ObjectAnimator.ofPropertyValuesHolder(logoView, pvh);
pvh = PropertyValuesHolder.ofKeyframe("scaleX", Keyframe.ofFloat(0f, 2.75f), Keyframe.ofFloat(1f, .1f));
ObjectAnimator scaleXAnimator = ObjectAnimator.ofPropertyValuesHolder(logoView, pvh);
pvh = PropertyValuesHolder.ofKeyframe("scaleY", Keyframe.ofFloat(0f, 2.75f), Keyframe.ofFloat(1f, .1f));
ObjectAnimator scaleYAnimator = ObjectAnimator.ofPropertyValuesHolder(logoView, pvh);
animatorSet.setInterpolator(new DecelerateInterpolator());
animatorSet.setDuration(9000).setStartDelay(9000);
animatorSet.playTogether(alphaAnimator, scaleXAnimator, scaleYAnimator);
animatorSet.start();
}
}
示例8: getFadeInAnimator
import android.animation.Keyframe; //導入依賴的package包/類
private static ObjectAnimator getFadeInAnimator(IntHolder target, int startAlpha, int endAlpha,
InvalidateUpdateListener updateListener) {
final float delayMultiplier = 0.25f;
final float transitionDurationMultiplier = 1f;
final float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier;
final int totalDuration = (int) (FADE_IN_DURATION * totalDurationMultiplier);
final float delayPoint = (delayMultiplier * FADE_IN_DURATION) / totalDuration;
final Keyframe kf0, kf1, kf2;
kf0 = Keyframe.ofInt(0f, startAlpha);
kf1 = Keyframe.ofInt(delayPoint, startAlpha);
kf2 = Keyframe.ofInt(1f, endAlpha);
final PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("value", kf0, kf1, kf2);
final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn);
animator.setDuration(totalDuration);
animator.addUpdateListener(updateListener);
return animator;
}
示例9: getAvatarAnimation
import android.animation.Keyframe; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private ObjectAnimator getAvatarAnimation(View view, int millis) {
PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofKeyframe(View.SCALE_X,
Keyframe.ofFloat(0f, 0.01f),
Keyframe.ofFloat(.035f, 0.45f),
Keyframe.ofFloat(.07f, 1.1f),
Keyframe.ofFloat(.09f, 1f),
Keyframe.ofFloat(.93f, .9f),
Keyframe.ofFloat(1f, 0f)
);
PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofKeyframe(View.SCALE_Y,
Keyframe.ofFloat(0f, 0.01f),
Keyframe.ofFloat(.035f, 0.45f),
Keyframe.ofFloat(.07f, 1.1f),
Keyframe.ofFloat(.09f, 1f),
Keyframe.ofFloat(.93f, .9f),
Keyframe.ofFloat(1f, 0f)
);
return ObjectAnimator.ofPropertyValuesHolder(view, pvhScaleX, pvhScaleY).
setDuration(millis);
}
示例10: fail
import android.animation.Keyframe; //導入依賴的package包/類
private void fail() {
loginBtn.setEnabled(true);
int delta = mOctocat.getResources().getDimensionPixelOffset(R.dimen.spacing_medium);
PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X,
Keyframe.ofFloat(0f, 0),
Keyframe.ofFloat(.10f, -delta),
Keyframe.ofFloat(.26f, delta),
Keyframe.ofFloat(.42f, -delta),
Keyframe.ofFloat(.58f, delta),
Keyframe.ofFloat(.74f, -delta),
Keyframe.ofFloat(.90f, delta),
Keyframe.ofFloat(1f, 0f)
);
ObjectAnimator.ofPropertyValuesHolder(mOctocat, pvhTranslateX)
.setDuration(500).start();
}
示例11: onClick
import android.animation.Keyframe; //導入依賴的package包/類
@Override
public void onClick(final View button) {
button.setEnabled(false);
View icon = findViewById(R.id.icon);
Keyframe keyframe1 = Keyframe.ofFloat(0f, 0f);
Keyframe keyframe2 = Keyframe.ofFloat(.4f, 90f);
Keyframe keyframe3 = Keyframe.ofFloat(.6f, 90f);
Keyframe keyframe4 = Keyframe.ofFloat(1f, 0f);
PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofKeyframe("rotation", keyframe1, keyframe2, keyframe3, keyframe4);
ObjectAnimator rotationAnim = ObjectAnimator.ofPropertyValuesHolder(icon, propertyValuesHolder);
rotationAnim.setDuration(5000);
rotationAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
button.setEnabled(true);
}
});
rotationAnim.setInterpolator(new AccelerateDecelerateInterpolator());
rotationAnim.start();
}
示例12: getPulseAnimator
import android.animation.Keyframe; //導入依賴的package包/類
/**
* Render an animator to pulsate a view in place.
*
* @param labelToAnimate the view to pulsate.
* @return The animator object. Use .start() to begin.
*/
public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio,
float increaseRatio) {
Keyframe k0 = Keyframe.ofFloat(0f, 1f);
Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio);
Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio);
Keyframe k3 = Keyframe.ofFloat(1f, 1f);
PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3);
PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3);
ObjectAnimator pulseAnimator =
ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY);
pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION);
return pulseAnimator;
}
示例13: nopeAnimation
import android.animation.Keyframe; //導入依賴的package包/類
/**
* Credit goes to Cyril Mottier.
* https://plus.google.com/+CyrilMottier/posts/FABaJhRMCuy
*
* @param view the {@link View} to animate.
* @return an {@link ObjectAnimator} that will play a 'nope' animation.
*/
public static ObjectAnimator nopeAnimation(View view, int delta) {
PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X,
Keyframe.ofFloat(0f, 0),
Keyframe.ofFloat(.10f, -delta),
Keyframe.ofFloat(.26f, delta),
Keyframe.ofFloat(.42f, -delta),
Keyframe.ofFloat(.58f, delta),
Keyframe.ofFloat(.74f, -delta),
Keyframe.ofFloat(.90f, delta),
Keyframe.ofFloat(1f, 0f)
);
return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX).
setDuration(500);
}
示例14: getFadeInAnimator
import android.animation.Keyframe; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static ObjectAnimator getFadeInAnimator(IntHolder target, int startAlpha, int endAlpha,
InvalidateUpdateListener updateListener) {
final float delayMultiplier = 0.25f;
final float transitionDurationMultiplier = 1f;
final float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier;
final int totalDuration = (int) (FADE_IN_DURATION * totalDurationMultiplier);
final float delayPoint = (delayMultiplier * FADE_IN_DURATION) / totalDuration;
final Keyframe kf0, kf1, kf2;
kf0 = Keyframe.ofInt(0f, startAlpha);
kf1 = Keyframe.ofInt(delayPoint, startAlpha);
kf2 = Keyframe.ofInt(1f, endAlpha);
final PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("value", kf0, kf1, kf2);
final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn);
animator.setDuration(totalDuration);
animator.addUpdateListener(updateListener);
return animator;
}
示例15: getPulseAnimator
import android.animation.Keyframe; //導入依賴的package包/類
public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio,
float increaseRatio) {
Keyframe k0 = Keyframe.ofFloat(0f, 1f);
Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio);
Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio);
Keyframe k3 = Keyframe.ofFloat(1f, 1f);
PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3);
PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3);
ObjectAnimator pulseAnimator =
ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX,
scaleY);
pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION);
return pulseAnimator;
}