Android Open Source - DragHelperView Header View Maximize Animation






From Project

Back to project page DragHelperView.

License

The source code is released under:

Apache License

If you think the Android project DragHelperView listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package so.library.draghelper.helper.animation;
//www .j  a  v a2 s  .c  om
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;

/**
 * Created by risedrag on 15. 1. 19..
 */
public class HeaderViewMaximizeAnimation extends Animation {
  final int startWidth;
  final int targetWidth;

  final float startTranslationX;
  final float startTranslationY;

  View view;

  public HeaderViewMaximizeAnimation(View view, int targetWidth) {
    this.view = view;
    this.targetWidth = targetWidth;

    startWidth = view.getWidth();
    startTranslationX = view.getTranslationX();
    startTranslationY = view.getTranslationY();
  }

  @Override
  protected void applyTransformation(float interpolatedTime, Transformation t) {
    int newWidth = (int) (startWidth + (targetWidth - startWidth) * interpolatedTime);

    //targetTranslation (0,0)

    float targetTranslationX = startTranslationX - (startTranslationX * interpolatedTime);
    float targetTranslationY = startTranslationY - (startTranslationY * interpolatedTime);

    view.setTranslationX(targetTranslationX);
    view.setTranslationY(targetTranslationY);
    view.getLayoutParams().width = newWidth;
    view.requestLayout();
  }

  @Override
  public void initialize(int width, int height, int parentWidth, int parentHeight) {
    super.initialize(width, height, parentWidth, parentHeight);
  }

  @Override
  public boolean willChangeBounds() {
    return true;
  }
}




Java Source Code List

so.library.draghelper.ApplicationTest.java
so.library.draghelper.MainActivity.java
so.library.draghelper.helper.OnStateChangedListener.java
so.library.draghelper.helper.SimpleDoubleTapListener.java
so.library.draghelper.helper.animation.HeaderViewMaximizeAnimation.java
so.library.draghelper.helper.animation.HeaderViewMinimizeAnimation.java
so.library.draghelper.helper.animation.SlideDownAnimation.java
so.library.draghelper.helper.animation.SlideUpAnimation.java
so.library.draghelper.helper.interpolator.SmoothInterpolator.java
so.library.draghelper.helper.view.DragHelperView.java