[android-developers] Re: Is it possible to draw to a home screen icon?
Actually the appwidgets do support standard animations such as
tweening and frame, but they are a bit of a hack job to get to work.
For tweening, you get use the layoutAnimation tag in your widgets XML.
It supports all the standard tween animations. When the remote views
object for that widget is first displayed, i.e. the widget added to
the home screen, the animation will show. But it wont show on
subsequent update calls to the same XML file, so you can duplicate
your widgets xml file, call it something else, and swap between them
when updating. Thus your tween animation will show every time you
update.
For frame animations, you can use prebuilt animation xml drawables and
load them into a indeterminateDrawable of a Indeterminate ProgressBar
element in your appwidget. As long as you are sensible about how long
the animation lasts for, and don't have it playing permanently this is
fine on the battery.
Mark, regarding the battery comment, could you or someone elaborate? I
have heard this countless times but with no justification. Is there
something intrinsically inefficient about updating an appwidget with
RemoteViews, more so than some other operation?
For example, if I am trying to "fake" a 5 second widget animation by
frequent updating an imageview over 5 seconds using RemoteViews, does
that consume more battery than doing a similar operation on a
imageview in an Activity?
Or is it more the assumption that such animations would be playing
permanently, which would not be best practice and I could see of
course would drain the battery?
It just seems to me that having a short animation play in response to
a certain situation, or being triggered by the user shouldn't drain
the battery any more than the same process in an activity, unless
RemoteViews itself is a battery drainer.
Thanks for any thoughts..
On Jun 6, 8:19 am, Mark Murphy <mmur...@commonsware.com> wrote:
> Rob Y. wrote:
> > I think it could be cuter if it were
> > possible to get a surface view that mapped to the home screen icon for
> > the app and animate that when the app is running and the icon is
> > visible.
>
> I am uncertain as to what "the icon" is. I can think of four possibilities:
>
> -- the icon in the launcher
> -- a shortcut icon the user put on their home screen
> -- a Notification icon in the status bar
> -- an app widget
>
> None of those can be animated in the form you describe. The icons are
> all resources, so at most you can try an AnimationDrawable resource, but
> I suspect most of those won't support the actual animating. An app
> widget does not support any of the standard animations, and attempting
> to fake it by extremely frequent updates will drain your battery quickly.
>
> You might give live wallpapers a try, though.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> _Android Programming Tutorials_ Version 2.0 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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home