I have 4 ImageViews which need to be moving from right to left. This is the sample video of my animation: https://docs.google.com/file/d/0B-Jk0rK9-8gUQTlUb3BrVGZEUHc/edit?usp=sharing
Here is the code I'm working on:
private void getCorrectObject() {
List<Integer> objects = new ArrayList<Integer>();
for(int arr : images){
objects.add(arr);
}
// Shuffle the collection
Collections.shuffle(objects);
iv.add((ImageView) findViewById(R.id.txtStage4_object1));
iv.add((ImageView) findViewById(R.id.txtStage4_object2));
iv.add((ImageView) findViewById(R.id.txtStage4_object3));
iv.add((ImageView) findViewById(R.id.txtStage4_object4));
Collections.shuffle(iv);
iv.get(0).setImageResource(images[0]); // Correct Image
iv.get(1).setImageResource(images[1]);
iv.get(2).setImageResource(images[2]);
iv.get(3).setImageResource(images[3]);
Animation accelerate = AnimationUtils.loadAnimation(this, R.anim.accelerate_2);
//accelerate.setRepeatCount(-1);
//accelerate.setRepeatMode(Animation.REVERSE);
iv.get(0).startAnimation(accelerate);
iv.get(1).startAnimation(accelerate);
iv.get(2).startAnimation(accelerate);
iv.get(3).startAnimation(accelerate);
for (int i = 0; i < tagList.length; i++) {
iv.get(i).setTag(tagList[i]);
iv.get(i).setOnTouchListener(new MyTouchListener());
}
}
XML:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate
android:duration="200"
android:fromXDelta="-100%"
android:fromYDelta="0%"
android:toXDelta="0%"
android:toYDelta="0%" />
</set>
But it's not doing as what I expected. Any ideas? I'd truly appreciate it. Thanks.