Closed JoanZapata closed 9 years ago
I still think this would be useful (as in convenient) but definitely something that we can live by without.
+1
I am using IconTextView
< com.joanzapata.iconify.widget.IconTextView ... android:text="{fa-cog spin}" .../>
spin isn't working . :(
@ch-muhammad-adil It has nothing to do with IconDrawable
. Please open a separate issue and specify which version of Iconify you're using.
This won't be fixed, as discussed in #56, a drawable can be used in many ways and spinning requires to regularly invalidate the drawable until the target view is detached. Detecting the fact that the view is detached is difficult and any mistake would create a memory leak.
Workarounds
Consider using an IconTextView
. If used on ImageView
, use an animation to rotate the ImageView
. If used elsewhere or rendered directly, progressively rotate the Canvas
before drawing the Drawable
would achieve the spinning effect.
ok thank you . I will manage it.
Regards, Muhammad Adil
On Tue, Sep 1, 2015 at 1:00 PM, Joan Zapata notifications@github.com wrote:
Closed #107 https://github.com/JoanZapata/android-iconify/issues/107.
— Reply to this email directly or view it on GitHub https://github.com/JoanZapata/android-iconify/issues/107#event-397499662 .
@JoanZapata: Drawable animations don't leak anything, because they depends on the draw()
callback instead of using a global scheduler (just like view animations). If a view is detached then it's no longer being drawn, and thus it's animation cycle is automatically stopped (including drawables).
For an example of drawable rotate animation, you can check out the hidden AnimatedRotateDrawable
implementation from the framework.
EDIT: Looking at the source, it seems like AnimatedRotateDrawable
does leak the view and run the animation indefinitely. However, it looks like AnimatedVectorDrawable
implements this properly.
Note that the same thing could be done with CustomTypefaceSpan
as well, but it would need to be understood that the text holds a reference to the view. Alternatively, you could use the built-in OnAttachStateChangeListener
instead of the custom HasOnViewAttachListener
to allow animation on the standard platform widgets if the minimum API level is >= Honeycomb MR 1.
I added support for spin animation in IconDrawable
in #134.
See #56:
@guilhermesgb Is it possible to make an IconDrawable spin (programatically)?