I've posted an article, Animation in Honeycomb, on the Android Developers blog. The article gives an overview of the new property animation system in Android 3.0. Check it out.
And while you wait, here's the demo reel for the article. I wanted to show some of the home screen interactions and API demos from the SDK that take advantage of the new animation framework. The sound track has nothing whatsoever to do with Android, but the video seemed to want audio. It was a sound decision.
15 comments:
Hi Chet,
I've created some nice custom animations to transition between Fragments in my Honeycomb app. This works very nicely until I hit the back button (even the stock android fade_in/fade_out animations don't work).
Do I need to do anything extra to enable this or is it just borked in this release of Honeycomb?
I submitted a bug report with more details: http://code.google.com/p/android/issues/detail?id=15623&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars
@Damian: I'll check out the bug report. I don't know off-hand what the problem would be. There are some situations of hiding fragments which are, in the current release, inherently un-animatable (because the things disappear immediately and cannot, therefore, be animated out). Also, some animations in layouts won't work correctly because of a similar immediate-removal issue. Whether these apply to your situation or not isn't clear without knowing more about what you're trying to do.
Thank you Chet, appreciate you taking a look at it. I just provided even more detail in the bug report. The framework is definitely doing some kind of animation on the back button press. Hopefully, you can make sense of the example I gave.
hi,
so far, for each animation i've tried on android, the final result doesn't work as expected .
for example, if i wish to make a button move from one point to another , after it moved to the second point, it isn't clickable there, but only on the first position .
is it possible now to overcome such a trivial thing without extra code ? if so, will it work for every animation and even while the animation is playing?
@Anonymous (feel free to leave your name in future comments, especially when you're asking a question...):
Yes, this now works as expected in Honeycomb. If you animate the new properties on View (like x/y or translationX/translationY), then the View itself will move, and will be clickable wherever it is. And when the animation finishes, the View will be where it looks like it is (no need for setFillAfter(), and in fact no such method exists on the new Animators).
You might still want to set up the View with new layout parameters so that it is being positioned correctly by the system and not just by these post-layout properties. But the new animations were created, in part, to overcome this restriction of the old system where the place the View as drawn was not necessarily the same as the place where the View existed and could be clicked.
@ Chet Haase :
this is good news.
when will such a behavior come (or maybe it already exist on 3.1?) ?
also, doesn't it mean that because no new code is needed, there will be compatibility problems?
or maybe it should be different from what i know of?
about being anonymus, sorry. will do it the next time.
i have to say i'm very happy for your quick comment and the work being done on android.
@Anonymous: This isn't capability that is just switched on automatically (and would thus have compatibility issues). Instead, it's *new* API that you can choose to use in your application if you target the 3.0 SDK or later. See the article for the details on the new API.
@Chet Haase :
i'm not sure i understand. has google created totally new functions for the whole animation concept, or is it just that i need to use the "use target sdk" (or something like that) in the manifest ...?
also, where is the article that you are talking about? hopefully i will understand the whole thing by reading there and reading the example code there...
oops, have you meant this article:
http://android-developers.blogspot.com/2011/02/animation-in-honeycomb.html
?
@Anonymous: Yes, that's the one. This blog entry (which starts, "I've posted an article, Animation in Honeycomb...") only exists to link to that article. I figured since you were commenting on this entry, you must know about the article.
Please read it and your questions should be answered.
suppose i write some animation code using the new API , will it also work on older versions of android ?
if so, it would be great , since i won't need to check which version the device has .
also, how well will it work? is there a catch? i mean, will a scale animation of a view actually scale the view , at least for the end of the animation?
@Anonymous: It's like any other API in the Android platform; it's available on devices that have that release (or later) installed. The animation API was introduced in 3.0, which is currently only on tablet devices.
@Chet Haase : so if i want to use an animation in my app , i have to choose if it's for 3.1 or below ?
i mean, can't i somehow enjoy both worlds, so that my code will use the best API that the device can give?
will android ever stop being so fragmented into so many versions? in my company , they still force us to make the app work for all versions , meaning that it should even work for 1.5 ...
Post a Comment