java animation android duration
10,649
Solution 1
In one of my app i write this code to move a block from left to right and its working well
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false" >
<rotate android:interpolator="@android:anim/accelerate_interpolator"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1500"
android:startOffset="1500"/>
<translate android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromYDelta="0"
android:toYDelta="-100%p"
android:duration="3000"/>
<translate android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:toXDelta="100%"
android:duration="1500"
android:startOffset="1500" />
</set>
Solution 2
Specify android:interpolator attribute of set tag with the value you desired. This interpolator just moves the object from the start point to the end point (or rotation) at a steady rate.
for ex::
android:interpolator="@android:anim/linear_interpolator"
Author by
Lpc_dark
I am a student in school and I am hoping to make some little apps for practice and just gather as much experience as possible. Love Programming and hope to be really good one day to start giving back :D
Updated on June 04, 2022Comments
-
Lpc_dark almost 2 years
This animation isn't animating it just instantly disappears no matter what duration I set here is the java code and xml
Java Code:
Animation shrink =AnimationUtils.loadAnimation(Page.this, R.anim.shrink); deleteMe.startAnimation(shrink);
XML File:
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true" android:shareInterpolator="true" android:interpolator="@android:anim/linear_interpolator" android:duration="10000"> <scale android:duration="10000" android:fillAfter="true" android:fromXScale="1.0" android:toXScale="0" > </scale> <alpha android:duration="10000" android:fromAlpha="1.0" android:toAlpha="0"> </alpha> </set>
-
Lpc_dark over 11 yearsDo i need to do this for each element or just for the root set element
-
Lpc_dark over 11 yearsI added this and updated the code and edited the post still doesn't work...*sigh*