I'm testing some XML tweeing animations in Android but I faced a bug using 'Set' and 'translate' in one XML file.
Please check the following source code.
Below is my XML code from 'res/layout/activity_main.xml' file.
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="${relativePackage}.${activityClass}" >
<ImageView
android:id="@+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/src" />
</LinearLayout>
Below is my Java code from 'MainActivity.java' file.
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class MainActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView imageview = (ImageView) findViewById(R.id.image1);
imageview.setAnimation(AnimationUtils.loadAnimation(this, R.anim.my_anim));
}
}
Below is my XML code from 'res/anim/my_anim.xml' file which causes a problem.
What is the problem?
The problem is, whenever I add one more 'translate' animation, the starting position changes.
It has nothing to do with the options like 'startOffset', 'fillAfter'..
And please DO NOT metion about 'AnimationListener'.
I already tried and it helped with this problem, but it has a different problem which I'll deal with later.
Anyway, you will know what I'm saying if you try the code below removing a 'translate' animation one by one.
When only one 'translate' is left, the starting position goes right.
Is this a bug?
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://ift.tt/nIICcg"
android:fillAfter="true" >
<translate
android:duration="3000"
android:fromXDelta="0%"
android:fromYDelta="0%"
android:toXDelta="100%"
android:toYDelta="0%" />
<translate
android:duration="3000"
android:fromXDelta="100%"
android:fromYDelta="0%"
android:startOffset="3000"
android:toXDelta="100%"
android:toYDelta="100%" />
<translate
android:duration="3000"
android:fromXDelta="100%"
android:fromYDelta="100%"
android:startOffset="6000"
android:toXDelta="0%"
android:toYDelta="100%" />
<translate
android:duration="3000"
android:fromXDelta="0%"
android:fromYDelta="100%"
android:startOffset="9000"
android:toXDelta="0%"
android:toYDelta="0%" />
</set>
No comments:
Post a Comment