I am attempting to place several images at specific points on my layout using ImageButton.layout(l,t,r,b). After they are arranged, I would like to execute an animation on each ImageButton. The trouble is, the animation starts before the positions of the ImageButtons has changed on the screen, causing the animation to look wrong.
How can I fix this? Here is a bit of code...
private void arrangeButtons()
{
int temp = 0;
for(ImageButton imageButtonButton :imageButtonList) {
imageButtonButton.setCurrentPositionIndex(temp);
int l = PositionsLeft[temp];
int t = PositionsTop[temp];
int r = PositionsRight[temp];
int b = positionsBottom[temp];
currentButton.layout(l,t,r,b);
temp++;
}
ViewGroup vg = (ViewGroup)findViewById(R.id.imageListFrame);
vg.invalidate();
vg.refreshDrawableState();
}
public static void rotateButtons() {
for(ImageButton imageButton : imageButtonList) {
RotateAnimation rotation = new RotateAnimation(0, 45, 25, 25);
imageButton.setAnimation(rotation);
imageButton.startAnimation(rotations);
}
}
public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.main);
arrangeButtons();
rotateButtons();
}
Any thoughts? Thanks!