Allow you to transition between views smoonthly by applying in & out animations on each View
without interrupting each other. This uses Pool mechanism.
If you want to transition ImageView I would recommend using Glide which save you trouble of OOM.
Check the ViewTransitionExample to see how to use them together.
Tip: In the example it does not use Bitmap
pool in Glide in order to avoid resuing bitmap that is still in animating, which causes a transition glitch.
Step 1. Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
compile 'com.github.zeroarst:ViewTransitioner:0.3'
}
ViewTransitioner<ImageView> vwTransitioner = new ViewTransitioner<>(mViewContainerLayout);
// In anim
final ObjectAnimator inAlphaAnim = new ObjectAnimator();
inAlphaAnim.setProperty(View.ALPHA);
inAlphaAnim.setFloatValues(1f);
inAlphaAnim.setDuration(1000);
// Out anim
final ObjectAnimator outAlphaAnim = new ObjectAnimator();
outAlphaAnim.setProperty(View.ALPHA);
outAlphaAnim.setFloatValues(0f);
outAlphaAnim.setDuration(1000);
vwTransitioner.transition(inAlphaAnim, outAlphaAnim, new ImageViewTransitionListener() {
@Override
public void onAcquired(ImageView view, boolean fromPool) {
// Init
view.setAlpha(0f);
view.setImageDrawable(resource);
}
});