AnimationDrawable animation on KeyboardView.Key android <p>I want to play animation on a key on custom keyboard. I've created the custom keyboard and everything is working fine, except the animation which is kind of popping up of key. I'm accomplishing it through AnimationDrawable. When <code>animation.start()</code> is called, only the first frame of animation is shown and it stucks there. Below is my simple code for animation. </p> <pre><code>enterKey.icon = ContextCompat.getDrawable(getActivity(), R.drawable.enter_button_animation); AnimationDrawable drawable = (AnimationDrawable) enterKey.icon; drawable.start(); mKeyboardView.invalidateAllKeys(); </code></pre> <p>Now I want to know how can I get the exact view handle of any key or why this animation is not working. <code>KeyboardView.Key.icon</code> is just a drawable. Given is my <code>enter_button_animation.xml</code>:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/selected" android:oneshot="false" &gt; &lt;item android:drawable="@drawable/enter_key_1" android:duration="50" /&gt; &lt;item android:drawable="@drawable/enter_key_2" android:duration="50" /&gt; &lt;item android:drawable="@drawable/enter_key_3" android:duration="50" /&gt; &lt;item android:drawable="@drawable/enter_key_4" android:duration="50" /&gt; &lt;/animation-list&gt; </code></pre> <p>Thanks in advance. </p>