Note that there are some explanatory texts on larger screens.

plurals
  1. POShowing both sides of a coin being flipped using Android standard animation
    primarykey
    data
    text
    <p>I'm very close to getting a "coin flipping" animation to work, but due to the limitations (bugs?) in the current Animation system - I cannot find a way to show BOTH sides of a coin flipping in the air.</p> <p>For example, I have the following Animation .XML:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false"&gt; &lt;scale android:repeatCount="17" android:repeatMode="reverse" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:fromXScale="1.0" android:toXScale="1.0" android:fromYScale="1.0" android:toYScale="0.0" android:pivotX="50%" android:pivotY="50%" android:fillEnabled="true" android:fillAfter="true" android:duration="60" /&gt; &lt;scale android:repeatCount="1" android:repeatMode="reverse" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:fromXScale="1.0" android:toXScale="2.0" android:fromYScale="1.0" android:toYScale="2.0" android:pivotX="50%" android:pivotY="50%" android:fillEnabled="true" android:fillAfter="true" android:duration="800" /&gt; &lt;translate android:repeatCount="1" android:repeatMode="reverse" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:fromXDelta="0%" android:toXDelta="0%" android:fromYDelta="0%" android:toYDelta="-150%" android:fillEnabled="true" android:fillAfter="true" android:duration="800" /&gt; &lt;/set&gt; </code></pre> <p>This "fakes" a flipping animation by scaling the coin on the Y-axis and reversing it on a loop. In combination to this, there's a scale to make the overall animation bigger, while also translating it up and down. But it is only ever gonna show the one side of the coin.</p> <p>I tried having two of these animations, each side of the coin, running at the same time, but I cannot find a way to stagger them due to the REPEATCOUNT not working when applied to an AnimationSet. Otherwise I could introduce some kind of delay after one anim (and before the other one) so they alternate, giving the illusion of a coin flipping.</p> <p>Does anyone know any way I can tweak this to get the desired result?</p> <p>I had thought of giving up and doing a frame-based anim (pre-render the flip as frames), but it appears you can't mix Frame &amp; Tween anims, so I'd lose the flip "height" and "distance" effects.</p> <p>(I have another issue when it comes to the coin landing - e.g. the final result is random, but I'm hoping I can switch in the actual result at the end?)</p> <p>Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload