[android-developers] Re: Alpha Animation not retaining state

2009-10-22 Thread Mark Murphy

bizack wrote:
 I have a simple animation:
 
 ?xml version=1.0 encoding=utf-8?
 set xmlns:android=http://schemas.android.com/apk/res/android;
 translate
   android:interpolator=@android:anim/decelerate_interpolator
   android:fromXDelta=0
   android:toXDelta=0
   android:fromYDelta=-13%p
   android:toYDelta=-1%p
   android:factor=1
   android:duration=1000/
 alpha android:fromAlpha=0
android:toAlpha=0.90
android:duration=1000/
 /set
 
 
 When this animation finishes, the alpha value jumps from 0.90 to 1.0.
 Why is this?

All animated Views return to their original state by default when the
animation ends.

One way to solve this is to add an AnimationListener, get control when
the animation ends, and then apply whatever permanent change you want to
make to the View.

Adding android:fillAfter=true and android:fillEnabled=true to your
XML should also do the trick, though I have not tried this yet.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

_Beginning Android_ from Apress Now Available!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Alpha Animation not retaining state

2009-10-22 Thread bizack

Yeah, I tried that but fillAfter and fillEnabled don't seem to do
anything (in this case).
Regardless, your suggestion about setting the state when the animation
ends works well.
Thanks for the help.

On Oct 22, 5:03 am, Mark Murphy mmur...@commonsware.com wrote:
 bizack wrote:
  I have a simple animation:

  ?xml version=1.0 encoding=utf-8?
  set xmlns:android=http://schemas.android.com/apk/res/android;
      translate
             android:interpolator=@android:anim/decelerate_interpolator
             android:fromXDelta=0
             android:toXDelta=0
             android:fromYDelta=-13%p
             android:toYDelta=-1%p
             android:factor=1
             android:duration=1000/
      alpha android:fromAlpha=0
             android:toAlpha=0.90
             android:duration=1000/
  /set

  When this animation finishes, the alpha value jumps from 0.90 to 1.0.
  Why is this?

 All animated Views return to their original state by default when the
 animation ends.

 One way to solve this is to add an AnimationListener, get control when
 the animation ends, and then apply whatever permanent change you want to
 make to the View.

 Adding android:fillAfter=true and android:fillEnabled=true to your
 XML should also do the trick, though I have not tried this yet.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://twitter.com/commonsguy

 _Beginning Android_ from Apress Now Available!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---