Java Code Examples for android.view.animation.Animation#setFillBefore()

The following examples show how to use android.view.animation.Animation#setFillBefore() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MicrophoneRecorderView.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
public void moveTo(float x) {
  this.lastPositionX = x;

  float offset = getOffset(x);

  Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, offset,
                                                        Animation.ABSOLUTE, offset,
                                                        Animation.RELATIVE_TO_SELF, -.25f,
                                                        Animation.RELATIVE_TO_SELF, -.25f);

  translateAnimation.setDuration(0);
  translateAnimation.setFillAfter(true);
  translateAnimation.setFillBefore(true);

  recordButtonFab.startAnimation(translateAnimation);
}
 
Example 2
Source File: DragSortGridView.java    From WayHoo with Apache License 2.0 6 votes vote down vote up
private void moveView(int fromPosition, int toPosition) {
	if (DEBUG_LOG) {
		L.d(TAG, "moveView from:" + fromPosition + ",to:" + toPosition);
	}

	final View from = getView(fromPosition);
	final View to = getView(toPosition);

	final Rect fromRect = new Rect();
	getLayout(from, fromRect);
	final Rect toRect = new Rect();
	getLayout(to, toRect);

	Animation translate = new TranslateAnimation(0, toRect.left
			- fromRect.left, 0, toRect.top - fromRect.top);
	translate.setDuration(150);
	translate.setFillEnabled(true);
	translate.setFillBefore(true);
	translate.setFillAfter(true);
	translate.setAnimationListener(new MoveViewAnimationListener(from, to
			.getLeft(), to.getTop()));

	from.startAnimation(translate);
}
 
Example 3
Source File: InputPanel.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
void moveTo(float offset) {
  Animation animation = new TranslateAnimation(Animation.ABSOLUTE, offset,
                                               Animation.ABSOLUTE, offset,
                                               Animation.RELATIVE_TO_SELF, 0,
                                               Animation.RELATIVE_TO_SELF, 0);

  animation.setDuration(0);
  animation.setFillAfter(true);
  animation.setFillBefore(true);

  slideToCancelView.startAnimation(animation);
}
 
Example 4
Source File: VoiceRecodingPanel.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
public void moveTo(float x) {
    float offset = getOffset(x);
    Animation animation = new TranslateAnimation(Animation.ABSOLUTE, offset,
            Animation.ABSOLUTE, offset,
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0);

    animation.setDuration(0);
    animation.setFillAfter(true);
    animation.setFillBefore(true);

    slideToCancelView.startAnimation(animation);
}
 
Example 5
Source File: InputPanel.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
public void moveTo(float x) {
  float     offset    = getOffset(x);
  Animation animation = new TranslateAnimation(Animation.ABSOLUTE, offset,
                                               Animation.ABSOLUTE, offset,
                                               Animation.RELATIVE_TO_SELF, 0,
                                               Animation.RELATIVE_TO_SELF, 0);

  animation.setDuration(0);
  animation.setFillAfter(true);
  animation.setFillBefore(true);

  slideToCancelView.startAnimation(animation);
}
 
Example 6
Source File: ViewMover.java    From viewmover with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the moving animation
 * <p>
 * Configures the moving animation based on moving params
 *
 * @param params params, which is used to configure the moving animation
 * @return moving animation
 */
private Animation createAnimation(MovingParams params) {
	Animation animation = new TranslateAnimation(0, params.getXAxisDelta(), 0, params.getYAxisDelta());
	animation.setFillEnabled(true);
	animation.setFillBefore(false);
	animation.setDuration(params.getAnimationDuration());
	Interpolator interpolator = params.getAnimationInterpolator();
	if (interpolator != null) {
		animation.setInterpolator(interpolator);
	}
	animation.setAnimationListener(new MoveAnimationListener(params));
	return animation;
}
 
Example 7
Source File: FigureSpinner.java    From MillSpinners with Apache License 2.0 4 votes vote down vote up
private void init() {
    final LayoutParams tempFigureLayoutParams = new LayoutParams(this.diameter, this.diameter);
    tempFigureLayoutParams.gravity = Gravity.CENTER;

    for (int i = 0; i < this.figureViews.length; i++) {
        final FigureView figureView = new FigureView(getContext());
        figureView.setColor(this.colors[i]);
        figureView.setFigureMargin(this.marginFigureCounter += this.marginFigure);

        if (this.isRounded) {
            figureView.setRounded();
        }

        Animation tempAnimation = new RotateAnimation(0, this.angle, this.radius, this.radius);
        tempAnimation.setStartOffset(this.startOffsetCounter);
        tempAnimation.setDuration(this.speed - this.startOffsetCounter);

        this.startOffsetCounter -= this.startOffset;

        figureView.setDrawingCacheEnabled(true);
        tempAnimation.setFillEnabled(true);
        tempAnimation.setFillBefore(true);
        tempAnimation.setFillAfter(true);
        tempAnimation.setRepeatMode(Animation.RESTART);
        tempAnimation.setRepeatCount(Animation.INFINITE);
        tempAnimation.setInterpolator(new AccelerateDecelerateInterpolator());

        figureView.startAnimation(tempAnimation);
        figureView.setLayoutParams(tempFigureLayoutParams);

        this.figureViews[i] = figureView;
        this.addView(figureView);
    }

    if (this.isRotated) {
        final Animation spinningAnimation = new RotateAnimation(0, 360, this.radius, this.radius);
        spinningAnimation.setDuration(this.speed * 5);
        spinningAnimation.setInterpolator(new LinearInterpolator());
        spinningAnimation.setRepeatMode(Animation.RESTART);
        spinningAnimation.setRepeatCount(Animation.INFINITE);
        startAnimation(spinningAnimation);
    }
}
 
Example 8
Source File: AnimationUtils.java    From proteus with Apache License 2.0 4 votes vote down vote up
public Animation instantiate(Context c) {
  Animation anim = createAnimation(c);
  if (null != anim) {
    if (null != detachWallpaper) {
      anim.setDetachWallpaper(detachWallpaper);
    }

    if (null != duration) {
      anim.setDuration(duration);
    }

    if (null != fillAfter) {
      anim.setFillAfter(fillAfter);
    }

    if (null != fillBefore) {
      anim.setFillBefore(fillBefore);
    }

    if (null != fillEnabled) {
      anim.setFillEnabled(fillEnabled);
    }

    if (null != interpolator) {
      Interpolator i = loadInterpolator(c, interpolator);
      if (null != i) {
        anim.setInterpolator(i);
      }
    }

    if (null != repeatCount) {
      anim.setRepeatCount(repeatCount);
    }

    if (null != repeatMode) {
      anim.setRepeatMode(repeatMode);
    }

    if (null != startOffset) {
      anim.setStartOffset(startOffset);
    }

    if (null != zAdjustment) {
      anim.setZAdjustment(zAdjustment);
    }
  }
  return anim;
}