Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid fade in and fade out with ImageView
    text
    copied!<p>I'm having some troubles with a slideshow I'm building.</p> <p>I've created 2 animations in xml for fade in and fade out:</p> <p><strong>fadein.xml</strong></p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;set xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:interpolator="@android:anim/accelerate_interpolator" android:duration="2000"/&gt; &lt;/set&gt; </code></pre> <p><strong>fadeout.xml</strong></p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;set xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:interpolator="@android:anim/accelerate_interpolator" android:duration="2000"/&gt; &lt;/set&gt; </code></pre> <p>What Im'trying to do, is to change images from an ImageView using the fade effect, so the currently displayed image will fade out, and another one will fade in. Considering that I have an image already set, I can fadeout this Image without problem, with this:</p> <pre><code> Animation fadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.your_fade_in_anim); imageView.startAnimation(fadeoutAnim); </code></pre> <p>But then, I set the next image to be displayed:</p> <pre><code> imageView.setImageBitmap(secondImage); </code></pre> <p>It just shows up in the imageView, and when i set the animation it hides the image, the fade it in... Is there any way to fix that, I mean, when I do <em>imageView.setImageBitmap(secondImage);</em> command, the image do not shows up immediately, and only when the fade in animation is executed?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload