user552400
user552400

Reputation:

Android tween animation blinks fast and doesn't work

I am trying to make a TextView scale and fade out. My TextView is inside a layout file that is included into my activity's layout with

<include android:id="@+id/hud" layout="@layout/hud" android:layout_alignParentBottom="true"/>

Now, I can apply a scale animation from within the Java code like this:

TextView multiplier = (TextView)findViewById(R.id.hudMultiplier);
ScaleAnimation s = new ScaleAnimation(1.0f, 3.0f, 1.0f,3.0f);
s.setDuration(5000);
multiplier.startAnimation(s);

And it works nicely, but I want that animation (and a bunch of others) from an xml file. So I made this file:

<?xml version="1.0" encoding="utf-8"?>
<set 
    xmlns:android="http://shemas.android.com/apk/res/android" 
    android:shareInterpolator="false">
    <scale
        android:pivotX="50%"
        android:pivotY="100%"
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:toXScale="10.0"
        android:toYScale="10.0"
        android:duration="5000"
        android:interpolator="@android:anim/accelerate_decelerate_interpolator" 
    />
    <alpha 
        android:fromAlpha="1.0"
        android:toAlpha="0.1"
        android:duration="2000"
        android:startOffset="2000">
    </alpha>
</set>

I am trying to apply the animation with this code:

TextView multiplier = (TextView)findViewById(R.id.hudMultiplier);
AnimationSet an = (AnimationSet) AnimationUtils.loadAnimation(getApplicationContext(), R.anim.multiplier);
multiplier.startAnimation(an);

What happens now is that the TextView blinks for a fraction of a second and nothing actually happens.

I've tried:

What am I missing?

The project is targeted at Android 1.6 and I'm testing in a 2.3 emulator.

Upvotes: 0

Views: 1542

Answers (2)

Vicky Kapadia
Vicky Kapadia

Reputation: 6081

try this:

an = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);

Upvotes: 0

StevieB
StevieB

Reputation: 596

This seems to make a difference, for me anyway!

Change shemas to schemas in the Set element.

    <?xml version="1.0" encoding="utf-8"?>
<set 
    xmlns:android="http://shemas.android.com/apk/res/android" 
    android:shareInterpolator="false">

Upvotes: 2

Related Questions