當前位置: 首頁>>代碼示例>>Java>>正文


Java Keyframe類代碼示例

本文整理匯總了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;
}
 
開發者ID:ttpho,項目名稱:TimePicker,代碼行數:22,代碼來源:Utils.java

示例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;
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:27,代碼來源:RadialSelectorView.java

示例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;
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:21,代碼來源:Utils.java

示例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);
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:18,代碼來源:ShakeListenerUtils.java

示例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;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:25,代碼來源:RadialSelectorView.java

示例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();
    }
}
 
開發者ID:Manabu-GT,項目名稱:StarWarsOpening,代碼行數:18,代碼來源:OpeningActivity.java

示例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();
    }
}
 
開發者ID:Manabu-GT,項目名稱:StarWarsOpening,代碼行數:26,代碼來源:OpeningActivity.java

示例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;
}
 
開發者ID:andela-kogunde,項目名稱:CheckSmarter,代碼行數:20,代碼來源:RadialTimePickerView.java

示例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);
}
 
開發者ID:Aracem,項目名稱:android-complex-animation,代碼行數:24,代碼來源:PostAJobAnimatedView.java

示例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();
    }
 
開發者ID:huanglizhuo,項目名稱:GitPath,代碼行數:18,代碼來源:LoginActivity.java

示例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();
}
 
開發者ID:IanGClifton,項目名稱:auid2,代碼行數:22,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:leavjenn,項目名稱:SmoothDateRangePicker,代碼行數:22,代碼來源:Utils.java

示例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);
}
 
開發者ID:tvbarthel,項目名稱:CameraColorPicker,代碼行數:23,代碼來源:Views.java

示例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;
}
 
開發者ID:TR4Android,項目名稱:AppCompat-Extension-Library,代碼行數:21,代碼來源:RadialTimePickerView.java

示例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;
}
 
開發者ID:novachevskyi,項目名稱:material-calendar-datepicker,代碼行數:17,代碼來源:Utils.java


注:本文中的android.animation.Keyframe類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。