I would like to translate an ImageView on the vertical ax and then on the horizontal one.
Here is my translate.xml code:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:interpolator="@android:anim/linear_interpolator" >
<translate
android:fillAfter="true"
android:fromYDelta="0%"
android:toYDelta="180%"
android:fromXDelta="50%"
android:toXDelta="50%"
android:duration="1500">
</translate>
<translate
android:fillAfter="true"
android:fromXDelta="0%"
android:toXDelta="-200%"
android:duration="1500">
</translate>
</set>
The code from Myactivity.java:
ImageView Img1 = (ImageView)findViewById(R.id.ImageView1);
anim_translate = AnimationUtils.loadAnimation(getApplicationContext(),translate);
//load animation
Img1.startAnimation(anim_translate);
I would like the image to move down, and THEN translate to left, but it only moves to the left corner, one time. thank you!
The solution is:
<translate
android:fromYDelta="0%"
android:toYDelta="170%"
android:fromXDelta="50%"
android:toXDelta="50%"
android:duration="1500"
android:fillAfter="true">
</translate>
<translate
android:startOffset="1500"
android:fillAfter="true"
android:fromXDelta="0%"
android:toXDelta="-200%"
android:duration="1500">
</translate>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.