Android Animator - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Animator class.

This code example shows how to use the following methods:addListener, playTogether, setDuration, start
        // Post this on the UI thread's message queue. It's needed for the items to be already measured 
        new Handler().post(new Runnable() {
 
            @Override 
            public void run() { 
                mSetAnim = new AnimatorSet();
                mTopImage.setLayerType(View.LAYER_TYPE_HARDWARE, null);
                mBottomImage.setLayerType(View.LAYER_TYPE_HARDWARE, null);
                mSetAnim.addListener(new Animator.AnimatorListener() {
                    @Override 
                    public void onAnimationStart(Animator animation) {
                    } 
 
                    @Override 
                    public void onAnimationEnd(Animator animation) {
                        clean(destActivity);
                    } 
 
                    @Override 
                    public void onAnimationCancel(Animator animation) {

7
CodeRank
This code example shows how to use the following methods:addListener, playTogether, setDuration, setInterpolator, start
This code example shows how to use the following methods:end, isRunning, setTarget, start
            container.start(view, closing);
        } 
    } 
 
    private void start(View view, boolean closing) {
        if (mEnterAnimation.isRunning()) {
            mEnterAnimation.end();
        } 
        if (mExitAnimation.isRunning()) {
            mExitAnimation.end();
        } 
        if (view.getVisibility() != View.VISIBLE) {
            if (!closing) {
                mEnterAnimation.setTarget(view);
                mEnterAnimation.start();
            } 
        } else if (closing) {
            mExitAnimation.setTarget(view);
            mExitAnimation.start();
        } else { 

7
CodeRank
This code example shows how to use the following methods:addListener, cancel
6
CodeRank
This code example shows how to use the following methods:addListener, play, start
        } else { 
            final long duration = getResources().getInteger(android.R.integer.config_shortAnimTime);
 
            // Animate if we have Honeycomb APIs, don't animate otherwise 
            mIsAnimating = true;
            AnimatorSet animatorSet = new AnimatorSet();
            mMasterView.setLayerType(LAYER_TYPE_HARDWARE, null);
            mDetailView.setLayerType(LAYER_TYPE_HARDWARE, null);
            animatorSet
                    .play(ObjectAnimator
                            .ofFloat(mMasterView, "translationX", translationX)
                            .setDuration(duration))
                    .with(ObjectAnimator
                            .ofFloat(mDetailView, "translationX", translationX)
                            .setDuration(duration));
            animatorSet.addListener(this);
            animatorSet.start();
 
            // For API level 12+, use this instead: 
            // mMasterView.animate().translationX().setDuration(duration); 

6
CodeRank
This code example shows how to use the following methods:addListener, start
6
CodeRank
This code example shows how to use the following methods:addListener, play, start
        } else { 
            final long duration = getResources().getInteger(android.R.integer.config_shortAnimTime);
 
            // Animate if we have Honeycomb APIs, don't animate otherwise 
            mIsAnimating = true;
            AnimatorSet animatorSet = new AnimatorSet();
            mMasterView.setLayerType(LAYER_TYPE_HARDWARE, null);
            mDetailView.setLayerType(LAYER_TYPE_HARDWARE, null);
            animatorSet
                    .play(ObjectAnimator
                            .ofFloat(mMasterView, "translationX", translationX)
                            .setDuration(duration))
                    .with(ObjectAnimator
                            .ofFloat(mDetailView, "translationX", translationX)
                            .setDuration(duration));
            animatorSet.addListener(this);
            animatorSet.start();
 
            // For API level 12+, use this instead: 
            // mMasterView.animate().translationX().setDuration(duration); 

6
CodeRank
This code example shows how to use the following methods:addListener, play, start
This code example shows how to use the following methods:addListener, end
6
CodeRank
This code example shows how to use the following methods:addListener, setDuration, start
            } 
 
            CrossFadeDrawable crossFadeDrawable = newCrossFadeDrawable(from, to);
            ObjectAnimator animator = crossFadeDrawable.getAnimator();
            imageView.setImageDrawable(crossFadeDrawable);
            animator.setDuration(ANIMATION_DURATION);
            animator.addListener(new AnimatorListenerAdapter() {
                @Override 
                public void onAnimationStart(Animator animation) {
                    if (FADE_DBG) {
                        log("cross-fade animation start (" 
                                + Integer.toHexString(from.hashCode()) + " -> "
                                + Integer.toHexString(to.hashCode()) + ")");
                    } 
                } 
 
                @Override 
                public void onAnimationEnd(Animator animation) {
                    if (FADE_DBG) {
                        log("cross-fade animation ended (" 

7
CodeRank

Related Android Animator Questions & Answers:

Other Android Animator Examples

33:	
34:	      @Override
35:	      public void onAnimationEnd(Animator animation) {
36:	        int nextX = randon.nextInt(width);
37:	        int nextY = randon.nextInt(height);

Read More

See Code Examples for Android Animator Methods: