Android startOffset animation broken or buggy?

I took the xml animation directly from the android documents and as far as I can see, it does not work on my emulator 2.1 update 1, nor on my 2.1 update 1 Galaxy S device.

In particular, I am trying to create an animation to throb the view (i.e. make it smaller than more in one animation) This is a very simple markup:

<?xml version="1.0" encoding="utf-8"?> 
<set 
        xmlns:android="http://schemas.android.com/apk/res/android"> 
        <scale 
                android:fromXScale="1.0" 
                android:toXScale="0.5" 
                android:fromYScale="1.0" 
                android:toYScale="0.5" 
                android:pivotX="50%" 
                android:pivotY="50%" 
                android:duration="1000" /> 
                <set android:startOffset="1000"> 
                        <scale 
                        android:fromXScale="0.5" 
                        android:toXScale="1.0" 
                        android:fromYScale="0.5" 
                        android:toYScale="1.0" 
                        android:pivotX="50%" 
                        android:pivotY="50%" 
                        android:duration="1000" /> 
                </set> 
</set> 

So, I am trying to achieve to reduce the view from its size to half of it in a second, then increase it to its original size for more than a second. To repeat the repetition, within two seconds it should start from the original → half size → the original.

, ( X/YScale 1.0), .

- ? . , !?

, "Tween Animation" http://developer.android.com/guide/topics/graphics/2d-graphics.html , . !

- ?

!

.

+5
3

<set>, <set> <scale>. , . , ( 0 ).

repeatMode , , , , :

<scale xmlns:android="http://schemas.android.com/apk/res/android" 
        android:repeatMode="reverse"
        android:fromXScale="1.0" 
        android:toXScale="0.5" 
        android:fromYScale="1.0" 
        android:toYScale="0.5" 
        android:pivotX="50%" 
        android:pivotY="50%" 
        android:duration="1000" />
+3

-, , , XML, <set>, !

<set android:startOffset="1000">

- / Android , <set> <set>

, , setStartOffset(), XML.

, , XML AnimationSet, / : 17662

:

setRepeatCount()/android: repeatCount

( repeatMode) XML. .

setDuration()/android:

AnimationSet WORKS ( ), XML

setFillAfter()/android: fillAfter

, XML . , fillEnabled true.

setFillBefore()/android: fillBefore

, / , XML

setFillEnabled()/android: fillEnabled

, / , XML. fillAfter, fillEnabled fillEnabled false.

setStartOffset()/android: startOffset

, XML.

, .

+5

. repeatMode = "-1". , .

res/anim/pulsate.xml:

<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" >
<scale
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromXScale="0.5"
    android:fromYScale="0.5"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatMode="reverse"
    android:repeatCount="-1"
    android:toXScale="1.0"
    android:toYScale="1.0" />

java :

Animation animPulsate = AnimationUtils.loadAnimation(JoinRecipeClubActivity.this, R.anim.pulsate);
ImageView ivFinger = (ImageView) findViewById(R.id.wivFinger);
ivFinger.startAnimation(animPulsate);
+2

All Articles