tags:

views:

55

answers:

1

I still try different basics with android, and now I'm stuck with animation. I'm trying to implement a simple animation. I've defined animation in xml file like this:

alpha android:interpolator="@android:anim/accelerate_interpolator" android:fromAlpha="0.0" android:toAlpha="1.0" duration="3000" repeatCount="infinite"

In my main view group I have an ImageView defined like this:

<ImageView android:id="@+id/someb" android:src="@drawable/earth_normal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5dip"/>

And this is from my starting activity class:

public class Ohayou extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    ImageView earth = (ImageView)findViewById(R.id.someb);
    Animation earthFadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_in);
    earth.startAnimation(earthFadeInAnimation);
}

It finds ImageView successfuly and creates animation. but when I start emulator ImageView just shows the original src image, not an animation. What am I doing wrong?

Thanks

A: 

Hi Rilakkuma

I see you have a correct code but I have doubt in your \anim\fade_in.xml, so try this

<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"&gt;
        <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:interpolator="@android:anim/accelerate_interpolator" 
android:duration="3000" android:repeatCount="infinite"/>
</set>
Jorgesys