Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animation problem

I'm trying to set up a simple animation that takes an image on the upper right hand side of the screen, moves it to the 30% point, moves in a circle, and them moves back to the edge. See the figure below. However, the current script does strange things, and while it ends up in the right place, almost nothing seems right before that. Also, depending on the Android version and screen size, it might do even more wild things. Any help would be much appreciated. Thanks!

enter image description here

A couple of key points. I want the left edge at the beginning to always be facing the direction of motion. I would like a circular motion where it moves from left to right, but if it can't be done, I'm not set on it, so long as the first part holds true.

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:shareInterpolator="true">
    <set>
        <translate
            android:fromXDelta="0%p" android:toXDelta="0%p"
            android:fromYDelta="00%p" android:toYDelta="20%p"
            android:duration="001" android:startOffset="0"/>
        <translate
            android:fromXDelta="0%p" android:toXDelta="-80%p"
            android:fromYDelta="00%p" android:toYDelta="0%p"
            android:duration="2000" android:startOffset="1"/>
    </set>
    <set>
        <rotate 
            android:fromDegrees="180"
            android:toDegrees="0" 
            android:pivotY="20%p"
            android:duration="1000"
            android:startOffset="2000"/>
        <translate
            android:fromXDelta="0%p" android:toXDelta="70%p"
            android:fromYDelta="00%p" android:toYDelta="0%p"
            android:duration="100" 
            android:startOffset="3000"/>
    </set>
</set>
like image 783
PearsonArtPhoto Avatar asked Jan 18 '26 16:01

PearsonArtPhoto


1 Answers

I did this in a new android project with a button in the main xml layout. It worked. All percentages are of parent size, relative to the view's position.

<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android" >

<translate android:fromXDelta="0%p" android:toXDelta="-80%p"
    android:fromYDelta="0%p" android:toYDelta="0%p" 
    android:duration="2000" />

<rotate android:fromDegrees="0" android:toDegrees="-180"
        android:pivotX="-70%p" android:pivotY="10%p" android:duration="1000"
        android:startOffset="2000" />

<translate  
    android:fromXDelta="0%p" android:toXDelta="80%p"
    android:fromYDelta="0%p" android:toYDelta="0%p" android:duration="2000"
    android:startOffset="3000" />

</set>
like image 79
Ronnie Avatar answered Jan 21 '26 08:01

Ronnie