I have a list of images(around 10) in my "image_list.xml" under "animation-list" specified with "item". And I have made one "fade_in.xml" file for fade in effect of the imgaes. The code works fine without errors.
The only problem I have is that the fade in effect appears in the first image but not in the other items of the image_list. Please tell me a way to make this possible so that all the images have fade in effect when they appear.My code is:
image_list.xml
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/sample1"
android:duration="2000"/>
<item android:drawable="@drawable/sample2"
android:duration="2000"/>
<item android:drawable="@drawable/sample3"
android:duration="2000"/>
<item android:drawable="@drawable/sample4"
android:duration="2000"/>
. . .
</animation-list>
ImagesActivity.java
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
ImageView img_change = (ImageView) findViewById(R.id.images);
Animation animationFadeIn = AnimationUtils.loadAnimation(this, R.anim.fade_in);
img_change.setBackgroundResource(R.drawable.image_list);
AnimationDrawable splashAnimation = (AnimationDrawable) img_change.getBackground();
if(hasFocus) {
img_change.setAnimation(animationFadeIn);
splashAnimation.start();
}}