Android ObjectAnimator - 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 ObjectAnimator class.

This code example shows how to use the following methods:ofFloat, setAlpha, setVisibility
        if (securityMessageDisplay != null) {
            securityMessageDisplay.showBouncer(duration);
        } 
        if (ecaView != null) {
            if (duration > 0) {
                Animator anim = ObjectAnimator.ofFloat(ecaView, "alpha", 0f);
                anim.setDuration(duration);
                anim.addListener(new AnimatorListenerAdapter() {
                    private boolean mCanceled;
                    @Override 
                    public void onAnimationCancel(Animator animation) {
                        // Fail safe and show the emergency button in onAnimationEnd() 
                        mCanceled = true;
                        ecaView.setAlpha(1f);
                    } 
                    @Override 
                    public void onAnimationEnd(Animator animation) {
                        ecaView.setVisibility(mCanceled ? View.VISIBLE : View.INVISIBLE);
                    } 
                }); 

9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:ofFloat, getMeasuredHeight, getMeasuredWidth, getTranslationX, setLayerType
        return mSwipeDirection == X ? vt.getXVelocity() :
                vt.getYVelocity();
    } 
 
    private ObjectAnimator createTranslationAnimation(View v, float newPos) {
        ObjectAnimator anim = ObjectAnimator.ofFloat(v,
                mSwipeDirection == X ? "translationX" : "translationY", newPos);
        return anim;
    } 
 
    private ObjectAnimator createDismissAnimation(View v, float newPos, int duration) {
        ObjectAnimator anim = createTranslationAnimation(v, newPos);
        anim.setInterpolator(sLinearInterpolator);
        anim.setDuration(duration);
        return anim;
    } 
 
    private float getPerpendicularVelocity(VelocityTracker vt) {
        return mSwipeDirection == X ? vt.getYVelocity() :
                vt.getXVelocity();

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:ofFloat, getVisibility
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:ofInt, setBounds, getPaint
    	/* Setup shape */ 
        shape = new OvalShape();
        shape.resize(50, 50);
 
    	/* Setup drawable */ 
		myShapeDrawable = new ShapeDrawable(shape);
		myShapeDrawable.getPaint().set(paint);
		myShapeDrawable.setBounds(125, 225, 275, 375);
 
    	/* Setup view (which will draw our drawable) */ 
		final MyView myView = new MyView(this);
		setContentView(myView);
 
    	/* Setup Animator */ 
		ObjectAnimator a = ObjectAnimator.ofInt(myShapeDrawable, "alpha", 0, 100);
		a.setDuration(10000);
 
		a.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        	/* Listen to the update event */ 
			@Override 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setDuration, start, addUpdateListener
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:ofPropertyValuesHolder, getHeight, getWidth, setPivotX, setPivotY
 
    public void onButtonClick(View view) {
        long animationDuration = (long) (BASE_DURATION * sAnimatorScale);
 
        // Scale around bottom/middle to simplify squash against the window bottom 
        view.setPivotX(view.getWidth() / 2);
        view.setPivotY(view.getHeight());
         
        // Animate the button down, accelerating, while also stretching in Y and squashing in X 
        PropertyValuesHolder pvhTY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y,
                mContainer.getHeight() - view.getHeight());
        PropertyValuesHolder pvhSX = PropertyValuesHolder.ofFloat(View.SCALE_X, .7f);
        PropertyValuesHolder pvhSY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1.2f);
        ObjectAnimator downAnim = ObjectAnimator.ofPropertyValuesHolder(
                view, pvhTY, pvhSX, pvhSY);
        downAnim.setInterpolator(sAccelerator);
        downAnim.setDuration((long) (animationDuration * 2));
 
        // Stretch in X, squash in Y, then reverse 
        pvhSX = PropertyValuesHolder.ofFloat(View.SCALE_X, 2);

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setDuration, start, addUpdateListener
    } 
 
    public void dismissRowAnimated(View child, int vel) {
        mSwipeHelper.dismissChild(child, vel);
    } 
 
    @Override 
    public void onFinishInflate() { 
        super.onFinishInflate(); 
        if (DEBUG) setWillNotDraw(false);
    } 
 
    @Override 
    public void onDraw(android.graphics.Canvas c) {
        super.onDraw(c);
        if (DEBUG) logLayoutTransition();
        if (DEBUG) {
            //Slog.d(TAG, "onDraw: canvas height: " + c.getHeight() + "px; measured height: " 
            //        + getMeasuredHeight() + "px"); 
            c.save();
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setDuration, start, setRepeatCount, setRepeatMode
        layout.addView(view, new FrameLayout.LayoutParams(480, 800, Gravity.CENTER));
 
        setContentView(layout);
 
        mAnimator = ObjectAnimator.ofInt(view, "offset", 0, PATTERN_SIZE - 1);
        mAnimator.setDuration(1500);
        mAnimator.setRepeatCount(ObjectAnimator.INFINITE);
        mAnimator.setRepeatMode(ObjectAnimator.REVERSE);
        mAnimator.start();
    } 
 
    @Override 
    protected void onDestroy() { 
        super.onDestroy(); 
        mAnimator.cancel();
    } 
 
    static class BitmapsView extends View {
        private final Paint mBitmapPaint;
        private final Bitmap mBitmap1;
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:ofFloat, getHeight, setLayerType
 
            @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) {
                        clean(destActivity);
                    } 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setDuration, start, setInterpolator
    /** 
     * Anticipate the future animation by rearing back, away from the direction of travel 
     */ 
    private void runPressAnim() { 
        downAnim = ObjectAnimator.ofFloat(this, "skewX", mOnLeft ? .5f : -.5f);
        downAnim.setDuration(2500);
        downAnim.setInterpolator(sDecelerator);
        downAnim.start();
    } 
 
    /** 
     * Finish the "anticipation" animation (skew the button back from the direction of 
     * travel), animate it to the other side of the screen, then un-skew the button 
     * with an Overshoot effect. 
     */ 
    private void runClickAnim() { 
        // Anticipation 
        ObjectAnimator finishDownAnim = null;
        if (downAnim != null && downAnim.isRunning()) {
            // finish the skew animation quickly 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android ObjectAnimator Questions & Answers:

Other Android ObjectAnimator Examples

12:	
13:	public class HitActivity extends Activity {
14:	  private ObjectAnimator animation1;
15:	  private ObjectAnimator animation2;
16:	  private Button button;
-
13:	public class HitActivity extends Activity {
14:	  private ObjectAnimator animation1;
15:	  private ObjectAnimator animation2;
16:	  private Button button;
17:	  private Random randon;

Read More

See Code Examples for Android ObjectAnimator Methods: