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


Java Animator類代碼示例

本文整理匯總了Java中android.animation.Animator的典型用法代碼示例。如果您正苦於以下問題:Java Animator類的具體用法?Java Animator怎麽用?Java Animator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Animator類屬於android.animation包,在下文中一共展示了Animator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onBind

import android.animation.Animator; //導入依賴的package包/類
@Override
public void onBind(Target view, Value o, final OnBindListener onBindListener) {
    ObjectAnimator animatorX = ObjectAnimator.ofFloat(view, View.ROTATION, 0f, 10f);
    ObjectAnimator animatorY = ObjectAnimator.ofFloat(view, View.ROTATION_X, 0f, 90f);
    AnimatorSet set = new AnimatorSet();
    set.setInterpolator(new AccelerateInterpolator(2f));
    set.setDuration(300);
    set.setStartDelay(80 * count);
    set.playTogether(animatorX, animatorY);
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            onBindListener.onBindDone();
        }
    });
    set.start();
    count++;
}
 
開發者ID:sedstrom,項目名稱:Witch-Android,代碼行數:20,代碼來源:FlipOut.java

示例2: showIcons

import android.animation.Animator; //導入依賴的package包/類
private void showIcons(final boolean show) {
  for (int i = 0; i < getChildCount(); i++) {
    final View view = getChildAt(i);
    int translation = menuAnchor == MENU_ANCHOR_BOTTOM ? view.getHeight() : -view.getHeight();
    view.setTranslationY(show ? translation : 0f);
    view.setScaleX(show ? 0f : 1f);
    view.setScaleY(show ? 0f : 1f);
    view.setVisibility(VISIBLE);
    view.setAlpha(show ? 0f : 1f);
    view.animate()
        .scaleX(show ? 1f : 0f)
        .scaleY(show ? 1f : 0f)
        .translationY(0f)
        .alpha(show ? 1f : 0f)
        .setInterpolator(DECELERATE_INTERPOLATOR)
        .setDuration(show ? animationDuration / 2 : animationDuration / 3)
        .setStartDelay(show ? animationDuration / 3 : 0)
        .setListener(new AnimatorListenerAdapter() {
          @Override public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            view.setVisibility(show ? VISIBLE : GONE);
          }
        })
        .start();
  }
}
 
開發者ID:zongkaili,項目名稱:MenuSet,代碼行數:27,代碼來源:TapBarMenu.java

示例3: onBindViewHolder

import android.animation.Animator; //導入依賴的package包/類
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (position < getItemCount() && (customHeaderView != null ? position <= stringList.size() : position < stringList.size()) && (customHeaderView != null ? position > 0 : true)) {

        ((ViewHolder) holder).textViewSample.setText(stringList.get(customHeaderView != null ? position - 1 : position));
        // ((ViewHolder) holder).itemView.setActivated(selectedItems.get(position, false));
    }
    if (!isFirstOnly || position > mLastPosition) {
        for (Animator anim : getAdapterAnimations(holder.itemView, AdapterAnimationType.ScaleIn)) {
            anim.setDuration(mDuration).start();
            anim.setInterpolator(mInterpolator);
        }
        mLastPosition = position;
    } else {
        ViewHelper.clear(holder.itemView);
    }

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:SimpleAnimationAdapter.java

示例4: animateInFrameDetails

import android.animation.Animator; //導入依賴的package包/類
private void animateInFrameDetails() {
    frameDetails.setVisibility(View.VISIBLE);
    ViewUtils.onLaidOut(frameDetails, new Runnable() {
        @Override
        public void run() {
            ObjectAnimator alpha = ObjectAnimator.ofFloat(frameDetails, View.ALPHA, 0.4f, 1f);
            ObjectAnimator translate = ofFloat(frameDetails, View.TRANSLATION_Y, frameDetails.getHeight() * 0.3f, 0f);

            AnimatorSet set = new AnimatorSet();
            set.playTogether(alpha, translate);
            set.setDuration(ANIM_DURATION);
            set.setInterpolator(new LinearOutSlowInInterpolator());
            set.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    frameMaster.setVisibility(View.GONE);
                }
            });
            set.start();
        }
    });
}
 
開發者ID:lurbas,項目名稱:MaterialMasterDetail,代碼行數:24,代碼來源:ContainersLayout.java

示例5: runIconScale

import android.animation.Animator; //導入依賴的package包/類
private void runIconScale(int delay, @DrawableRes int drawable, int color){
    soundPlay.animate()
            .scaleY(0)
            .scaleX(0)
            .setDuration(duration(R.integer.short_delay))
            .setStartDelay(delay)
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    trackTitle.setTextColor(color);
                    soundPlay.setImageDrawable(ContextCompat.getDrawable(getContext(),drawable));
                    soundPlay.animate()
                            .scaleX(1)
                            .scaleY(1)
                            .setDuration(duration(R.integer.scale_duration))
                            .setListener(null).start();
                }
            }).start();
}
 
開發者ID:vpaliyX,項目名稱:Material-Motion,代碼行數:21,代碼來源:PlayerFragment.java

示例6: getAnimators

import android.animation.Animator; //導入依賴的package包/類
@Override
public List<Animator> getAnimators() {
    final List<Animator> animations = new ArrayList<>();
    calculate();
    if (mCameraDistance != null) {
        final ValueAnimator animator = ValueAnimator.ofFloat(mCurrentCameraDistance, mCameraDistance);
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                viewToMove.setCameraDistance((float) valueAnimator.getAnimatedValue());
            }
        });
        animations.add(animator);
    }
    return animations;
}
 
開發者ID:florent37,項目名稱:ExpectAnim,代碼行數:17,代碼來源:ExpectAnimCameraDistanceManager.java

示例7: createAnimation

import android.animation.Animator; //導入依賴的package包/類
public List<Animator> createAnimation() {
    List<Animator> animators = new ArrayList<>();
    int[] delays = new int[]{120, 240, 360};
    for (int i = 0; i < 3; i++) {
        final int index = i;

        ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1);

        scaleAnim.setDuration(750);
        scaleAnim.setRepeatCount(-1);
        scaleAnim.setStartDelay(delays[i]);

        scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                scaleFloats[index] = (float) animation.getAnimatedValue();
                postInvalidate();

            }
        });
        scaleAnim.start();
        animators.add(scaleAnim);
    }
    return animators;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:26,代碼來源:ProgressIndicatorView.java

示例8: createEnterTabSwitcherModeAnimation

import android.animation.Animator; //導入依賴的package包/類
private ObjectAnimator createEnterTabSwitcherModeAnimation() {
    ObjectAnimator enterAnimation =
            ObjectAnimator.ofFloat(this, mTabSwitcherModePercentProperty, 1.f);
    enterAnimation.setDuration(TAB_SWITCHER_MODE_ENTER_ANIMATION_DURATION_MS);
    enterAnimation.setInterpolator(new LinearInterpolator());
    enterAnimation.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            // This is to deal with the view going invisible when resuming the activity and
            // running this animation.  The view is still there and clickable but does not
            // render and only a layout triggers a refresh.  See crbug.com/306890.
            if (!mToggleTabStackButton.isEnabled()) requestLayout();
        }
    });

    return enterAnimation;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:18,代碼來源:ToolbarPhone.java

示例9: setDimVisibility

import android.animation.Animator; //導入依賴的package包/類
private void setDimVisibility(final boolean visible) {
    Animator animator;
    if (visible) {
        dimView.setVisibility(VISIBLE);
        animator = ObjectAnimator.ofFloat(dimView, "alpha", 0.0f, 1.0f);
    } else {
        animator = ObjectAnimator.ofFloat(dimView, "alpha", 1.0f, 0.0f);
    }
    animator.addListener(new AnimatorListenerAdapterProxy() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (!visible) {
                dimView.setVisibility(GONE);
            }
        }
    });
    animator.setDuration(200);
    animator.start();
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:20,代碼來源:PhotoPaintView.java

示例10: show

import android.animation.Animator; //導入依賴的package包/類
/**
 * 向四周伸張,直到完成顯示。
 */
@SuppressLint("NewApi")
public static void show(View myView, float startRadius, long durationMills) {
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
        myView.setVisibility(View.VISIBLE);
        return;
    }

    int cx = (myView.getLeft() + myView.getRight()) / 2;
    int cy = (myView.getTop() + myView.getBottom()) / 2;

    int w = myView.getWidth();
    int h = myView.getHeight();

    // 勾股定理 & 進一法
    int finalRadius = (int) Math.sqrt(w * w + h * h) + 1;

    Animator anim =
            ViewAnimationUtils.createCircularReveal(myView, cx, cy, startRadius, finalRadius);
    myView.setVisibility(View.VISIBLE);
    anim.setDuration(durationMills);
    anim.start();
}
 
開發者ID:InnoFang,項目名稱:Android-Code-Demos,代碼行數:26,代碼來源:CircularAnimUtil.java

示例11: hideRecordedAudioPanel

import android.animation.Animator; //導入依賴的package包/類
private void hideRecordedAudioPanel() {
    audioToSendPath = null;
    audioToSend = null;
    audioToSendMessageObject = null;
    AnimatorSet AnimatorSet = new AnimatorSet();
    AnimatorSet.playTogether(
            ObjectAnimator.ofFloat(recordedAudioPanel, "alpha", 0.0f)
    );
    AnimatorSet.setDuration(200);
    AnimatorSet.addListener(new AnimatorListenerAdapterProxy() {
        @Override
        public void onAnimationEnd(Animator animation) {
            recordedAudioPanel.setVisibility(GONE);

        }
    });
    AnimatorSet.start();
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:19,代碼來源:ChatActivityEnterView.java

示例12: fadeOut

import android.animation.Animator; //導入依賴的package包/類
private void fadeOut() {
    contentView.setAlpha(0f);
    contentView.setVisibility(View.VISIBLE);

    contentView.animate()
            .alpha(1f)
            .setDuration(getResources().getInteger(
                    android.R.integer.config_longAnimTime))
            .setListener(null);

    loadingView.animate()
            .alpha(0f)
            .setDuration(getResources().getInteger(
                    android.R.integer.config_longAnimTime))
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    loadingView.setVisibility(View.GONE);
                }
            });
}
 
開發者ID:secompufscar,項目名稱:app_secompufscar,代碼行數:22,代碼來源:MainActivity.java

示例13: exitReveal

import android.animation.Animator; //導入依賴的package包/類
private void exitReveal(final View icon, final View toolbar) {

        // get the center for the clipping circle
        int cx = getRelativeLeft(icon) + icon.getMeasuredWidth() / 2;
        int cy = getRelativeTop(icon);

        // get the initial radius for the clipping circle
        int initialRadius = Math.max(toolbar.getWidth(), toolbar.getHeight());

        // create the animation (the final radius is zero)
        Animator anim =
                ViewAnimationUtils.createCircularReveal(toolbar, cx, cy, initialRadius, 0);

        // make the view invisible when the animation is done
        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                toolbar.setVisibility(View.INVISIBLE);
            }
        });

        anim.setDuration(Constant.SEARCH_REVEAL_DURATION);
        // start the animation
        anim.start();
    }
 
開發者ID:PacktPublishing,項目名稱:Expert-Android-Programming,代碼行數:27,代碼來源:HomeActivity.java

示例14: performShowAnimation

import android.animation.Animator; //導入依賴的package包/類
private void performShowAnimation() {
    contextMenuView.setPivotX(contextMenuView.getWidth() / 2);
    contextMenuView.setPivotY(contextMenuView.getHeight());
    contextMenuView.setScaleX(0.1f);
    contextMenuView.setScaleY(0.1f);
    contextMenuView.animate()
            .scaleX(1f).scaleY(1f)
            .setDuration(150)
            .setInterpolator(new OvershootInterpolator())
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    isContextMenuShowing = false;
                }
            });
}
 
開發者ID:lianghao208,項目名稱:InstaFlickr,代碼行數:17,代碼來源:FeedContextMenuManager.java

示例15: Play

import android.animation.Animator; //導入依賴的package包/類
void Play(int val){
    final ImageView iv = top;
    top = btm;
    btm = creatImg();
    btm.setImageBitmap(BM);
    addView(btm,0);
    Set = new AnimatorSet();
    Set.setInterpolator(Ui.cd.TH);
    Set.playTogether(ObjectAnimator.ofFloat(iv, "X",val));
    Set.setDuration(500).start();
    Set.addListener(new animLis(){
        @Override
        public void onAnimationEnd(Animator animation) {
            imgSlider.this.removeView(iv);
        }
    });
}
 
開發者ID:KishanV,項目名稱:Android-Music-Player,代碼行數:18,代碼來源:imgSlider.java


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