Essential Android Animators edit forum

TransitionDrawable animation

This example displays a transaction for an image view with only two images.(can use more images as well one after the other for the first and second layer positions after each transaction as a loop)

<resources>

    <array
        name="splash_images">
        <item>@drawable/spash_imge_first</item>
        <item>@drawable/spash_img_second</item>
    </array>

</resources>

—``` private Drawable[] backgroundsDrawableArrayForTransition; private TransitionDrawable transitionDrawable;

private void backgroundAnimTransAction() {

// set res image array
Resources resources = getResources();
TypedArray icons = resources.obtainTypedArray(R.array.splash_images);

@SuppressWarnings("ResourceType")
Drawable drawable = icons.getDrawable(0);    // ending image

@SuppressWarnings("ResourceType")
Drawable drawableTwo = icons.getDrawable(1);   // starting image

backgroundsDrawableArrayForTransition = new Drawable[2];
backgroundsDrawableArrayForTransition[0] = drawable;
backgroundsDrawableArrayForTransition[1] = drawableTwo;
transitionDrawable = new TransitionDrawable(backgroundsDrawableArrayForTransition);

// your image view here - backgroundImageView
backgroundImageView.setImageDrawable(transitionDrawable);
transitionDrawable.startTransition(4000);

transitionDrawable.setCrossFadeEnabled(false); // call public methods

}

```


Table Of Contents
39 ACRA
56 Animators
64 Menu
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close