Question

I have an ImageSwitcher and I'm using it to create a slideshow. I can control the duration that an image is displayed for but how do I control the duration of the transition between the images. I want to increase that duration because the outAnimation of the previous image and the inAnimation of the next image, look like they merge and it doesn't look good.

Était-ce utile?

La solution

Define custom in and out animations for your ImageSwitcher:

ImageSwitcher imageSwitcher = (ImageSwitcher) findViewById(R.id.ImageSwitcher);
imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this,
    R.anim.custom_fade_in));
imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this,
    R.anim.custom_fade_out));

and in your animation xmls set your duration:

<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
    ....
    android:duration="1000"/>
</set> 
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top