Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android material design animation

I'm looking to have an animation that transitions a TextView with a circle background to a rectangular header. Right now I'm just using the built in animation:

String transitionName = getString(R.string.my_transition);
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this,
                myTextView, transitionName);
startActivity(detailIntent, options.toBundle());

This works, but the animation isn't that smooth, when I transition back the rectangle header goes to a square that represents the textview and then creates the circle background. I would like to use this animation from the Material Design site. I'm not sure if this code is already provided by Google or some other source. If not, I have never made my own animation before so what would be a good tutorial on creating this? Any help would be appreciated.

like image 454
Ryan Sayles Avatar asked Jul 30 '26 04:07

Ryan Sayles


1 Answers

Check these out :

  1. http://www.codeproject.com/Articles/825739/Article-Beginners-Guide-to-Android-Animation-Gr

  2. Morph a retangler view into a circle

These are the interpolators available in android :

AccelerateDecelerateInterpolator

@android:anim/accelerate_decelerate_interpolator

AccelerateInterpolator

@android:anim/accelerate_interpolator

AnticipateInterpolator

@android:anim/anticipate_interpolator

AnticipateOvershootInterpolator

@android:anim/anticipate_overshoot_interpolator

BounceInterpolator

@android:anim/bounce_interpolator

CycleInterpolator

@android:anim/cycle_interpolator

DecelerateInterpolator

@android:anim/decelerate_interpolator

LinearInterpolator

@android:anim/linear_interpolator

OvershootInterpolator

@android:anim/overshoot_interpolator

This is how you can create an animator or just an anim using resource/animator or resource/anim respectively.

<set
  android:ordering=["together" | "sequentially"]>

    <objectAnimator
        android:propertyName="string"
        android:duration="int"
        android:valueFrom="float | int | color"
        android:valueTo="float | int | color"
        android:startOffset="int"
        android:repeatCount="int"
        android:repeatMode=["repeat" | "reverse"]
        android:valueType=["intType" | "floatType"]/>

    <animator
        android:duration="int"
        android:valueFrom="float | int | color"
        android:valueTo="float | int | color"
        android:startOffset="int"
        android:repeatCount="int"
        android:repeatMode=["repeat" | "reverse"]
        android:valueType=["intType" | "floatType"]/>

    <set>
        ...
    </set>
</set>

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!