3
\$\begingroup\$

I want to add animation to my game board when updating tile positions. I can start an animation at the right point, but there's a catch: When the translate animation starts, it seems like the animation is confined within the tile (button) or is just hidden behind another button. Instead, I want it to look like it is moving.

This is what happens:

actual scenario

This is what I want to happen:

desired scenario

Here's how I start the animations:

    Animation tile_up = AnimationUtils.loadAnimation(this, R.anim.tile_up);
    // This was a valid move. Add to moves and enable undo for this
    for(int i = 0; i < 5; i++)
    {
        buttons[x][i].startAnimation(tile_up);
    }

Here's the animation spec (in res/anim/tile_up.xml):

    <?xml version="1.0" encoding="utf-8"?>
    <translate
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:shareInterpolator="true"
        android:fromYDelta="100%p"
        android:toYDelta="0%p"
        android:duration="100"/>

How can I fix this?

\$\endgroup\$
0
\$\begingroup\$

Okay, finally after 6-7 hours of searching through the internet i finally found the answer i was looking for. Since my layout is made up of nested LinearLayouts, I had to add a android:clipChildren="false" attribute to all my LinearLayouts(button parents).

Seems like the issue was the linear layouts didn't want to let it's childs outside to play. Which is understandable, and they're great parents none the less. But i had to make them let go. (Joking here)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.